diff --git a/websocket-sharp/Server/IWebSocketSession.cs b/websocket-sharp/Server/IWebSocketSession.cs index d86c19ef..8d5a4bbf 100644 --- a/websocket-sharp/Server/IWebSocketSession.cs +++ b/websocket-sharp/Server/IWebSocketSession.cs @@ -55,11 +55,10 @@ namespace WebSocketSharp.Server string ID { get; } /// - /// Gets the subprotocol of the used in the session. + /// Gets the WebSocket subprotocol used in the session. /// /// - /// A that represents the subprotocol of the used - /// in the session if any. + /// A that represents the subprotocol if any. /// string Protocol { get; } diff --git a/websocket-sharp/Server/WebSocketService.cs b/websocket-sharp/Server/WebSocketService.cs index e0226a9f..3efdc3de 100644 --- a/websocket-sharp/Server/WebSocketService.cs +++ b/websocket-sharp/Server/WebSocketService.cs @@ -44,14 +44,13 @@ namespace WebSocketSharp.Server { #region Private Fields - private WebSocketContext _context; - private Func - _cookiesValidator; - private Func _originValidator; - private string _protocol; - private WebSocketSessionManager _sessions; - private DateTime _start; - private WebSocket _websocket; + private WebSocketContext _context; + private Func _cookiesValidator; + private Func _originValidator; + private string _protocol; + private WebSocketSessionManager _sessions; + private DateTime _start; + private WebSocket _websocket; #endregion @@ -192,7 +191,7 @@ namespace WebSocketSharp.Server } /// - /// Gets or sets the subprotocol of the used in the current session. + /// Gets or sets the WebSocket subprotocol used in the current session. /// /// /// Set operation of this property is available before the WebSocket connection has been @@ -200,16 +199,13 @@ namespace WebSocketSharp.Server /// /// /// - /// A that represents the subprotocol of the - /// used in the current session if any. + /// A that represents the subprotocol if any. The default value is + /// . /// /// /// The value to set must be a token defined in /// RFC 2616. /// - /// - /// The default value is . - /// /// public string Protocol { get { @@ -219,11 +215,13 @@ namespace WebSocketSharp.Server } set { - if (State == WebSocketState.Connecting && - value != null && - value.Length > 0 && - value.IsToken ()) - _protocol = value; + if (State != WebSocketState.Connecting) + return; + + if (value != null && (value.Length == 0 || !value.IsToken ())) + return; + + _protocol = value; } }