From eaaba53442b440fc7d8ca7ad2318e89bd2ae464b Mon Sep 17 00:00:00 2001 From: sta Date: Sat, 30 Jan 2016 16:11:34 +0900 Subject: [PATCH] [Modify] Replace it --- websocket-sharp/WebSocket.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/websocket-sharp/WebSocket.cs b/websocket-sharp/WebSocket.cs index ba07bf8f..73dc3138 100644 --- a/websocket-sharp/WebSocket.cs +++ b/websocket-sharp/WebSocket.cs @@ -677,11 +677,8 @@ namespace WebSocketSharp throw new WebSocketException (CloseStatusCode.PolicyViolation, msg); } - if (_protocol != null - && !_context.SecWebSocketProtocols.Contains (protocol => protocol == _protocol) - ) { - _protocol = null; - } + if (_protocol != null) + processSecWebSocketProtocolHeader (_context.SecWebSocketProtocols); if (!_ignoreExtensions) processSecWebSocketExtensionsHeader (_context.Headers["Sec-WebSocket-Extensions"]); @@ -1257,6 +1254,15 @@ namespace WebSocketSharp } } + // As server + private void processSecWebSocketProtocolHeader (IEnumerable values) + { + if (values.Contains (p => p == _protocol)) + return; + + _protocol = null; + } + private bool processUnsupportedFrame (WebSocketFrame frame) { _logger.Fatal ("An unsupported frame:" + frame.PrintToString (false));