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; } string ID { get; }
/// <summary> /// <summary>
/// Gets the subprotocol of the <see cref="WebSocket"/> used in the session. /// Gets the WebSocket subprotocol used in the session.
/// </summary> /// </summary>
/// <value> /// <value>
/// A <see cref="string"/> that represents the subprotocol of the <see cref="WebSocket"/> used /// A <see cref="string"/> that represents the subprotocol if any.
/// in the session if any.
/// </value> /// </value>
string Protocol { get; } string Protocol { get; }

View File

@ -45,8 +45,7 @@ namespace WebSocketSharp.Server
#region Private Fields #region Private Fields
private WebSocketContext _context; private WebSocketContext _context;
private Func<CookieCollection, CookieCollection, bool> private Func<CookieCollection, CookieCollection, bool> _cookiesValidator;
_cookiesValidator;
private Func<string, bool> _originValidator; private Func<string, bool> _originValidator;
private string _protocol; private string _protocol;
private WebSocketSessionManager _sessions; private WebSocketSessionManager _sessions;
@ -192,7 +191,7 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <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> /// </summary>
/// <remarks> /// <remarks>
/// Set operation of this property is available before the WebSocket connection has been /// Set operation of this property is available before the WebSocket connection has been
@ -200,16 +199,13 @@ namespace WebSocketSharp.Server
/// </remarks> /// </remarks>
/// <value> /// <value>
/// <para> /// <para>
/// A <see cref="string"/> that represents the subprotocol of the <see cref="WebSocket"/> /// A <see cref="string"/> that represents the subprotocol if any. The default value is
/// used in the current session if any. /// <see cref="String.Empty"/>.
/// </para> /// </para>
/// <para> /// <para>
/// The value to set must be a token defined in /// The value to set must be a token defined in
/// <see href="http://tools.ietf.org/html/rfc2616#section-2.2">RFC 2616</see>. /// <see href="http://tools.ietf.org/html/rfc2616#section-2.2">RFC 2616</see>.
/// </para> /// </para>
/// <para>
/// The default value is <see cref="String.Empty"/>.
/// </para>
/// </value> /// </value>
public string Protocol { public string Protocol {
get { get {
@ -219,10 +215,12 @@ namespace WebSocketSharp.Server
} }
set { set {
if (State == WebSocketState.Connecting && if (State != WebSocketState.Connecting)
value != null && return;
value.Length > 0 &&
value.IsToken ()) if (value != null && (value.Length == 0 || !value.IsToken ()))
return;
_protocol = value; _protocol = value;
} }
} }