Fix a few for Protocol properties

This commit is contained in:
sta 2014-05-07 15:42:14 +09:00
parent 85e567bd72
commit 470a254a19
2 changed files with 19 additions and 22 deletions

View File

@ -55,11 +55,10 @@ namespace WebSocketSharp.Server
string ID { get; }
/// <summary>
/// Gets the subprotocol of the <see cref="WebSocket"/> used in the session.
/// Gets the WebSocket subprotocol used in the session.
/// </summary>
/// <value>
/// A <see cref="string"/> that represents the subprotocol of the <see cref="WebSocket"/> used
/// in the session if any.
/// A <see cref="string"/> that represents the subprotocol if any.
/// </value>
string Protocol { get; }

View File

@ -44,14 +44,13 @@ namespace WebSocketSharp.Server
{
#region Private Fields
private WebSocketContext _context;
private Func<CookieCollection, CookieCollection, bool>
_cookiesValidator;
private Func<string, bool> _originValidator;
private string _protocol;
private WebSocketSessionManager _sessions;
private DateTime _start;
private WebSocket _websocket;
private WebSocketContext _context;
private Func<CookieCollection, CookieCollection, bool> _cookiesValidator;
private Func<string, bool> _originValidator;
private string _protocol;
private WebSocketSessionManager _sessions;
private DateTime _start;
private WebSocket _websocket;
#endregion
@ -192,7 +191,7 @@ namespace WebSocketSharp.Server
}
/// <summary>
/// Gets or sets the subprotocol of the <see cref="WebSocket"/> used in the current session.
/// Gets or sets the WebSocket subprotocol used in the current session.
/// </summary>
/// <remarks>
/// Set operation of this property is available before the WebSocket connection has been
@ -200,16 +199,13 @@ namespace WebSocketSharp.Server
/// </remarks>
/// <value>
/// <para>
/// A <see cref="string"/> that represents the subprotocol of the <see cref="WebSocket"/>
/// used in the current session if any.
/// A <see cref="string"/> that represents the subprotocol if any. The default value is
/// <see cref="String.Empty"/>.
/// </para>
/// <para>
/// The value to set must be a token defined in
/// <see href="http://tools.ietf.org/html/rfc2616#section-2.2">RFC 2616</see>.
/// </para>
/// <para>
/// The default value is <see cref="String.Empty"/>.
/// </para>
/// </value>
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;
}
}