Refactored a few for WebSocketBehavior.cs
This commit is contained in:
parent
1eabd45f24
commit
4876461209
@ -51,7 +51,7 @@ namespace WebSocketSharp.Server
|
||||
private Func<string, bool> _originValidator;
|
||||
private string _protocol;
|
||||
private WebSocketSessionManager _sessions;
|
||||
private DateTime _start;
|
||||
private DateTime _startTime;
|
||||
private WebSocket _websocket;
|
||||
|
||||
#endregion
|
||||
@ -63,7 +63,7 @@ namespace WebSocketSharp.Server
|
||||
/// </summary>
|
||||
protected WebSocketBehavior ()
|
||||
{
|
||||
_start = DateTime.MaxValue;
|
||||
_startTime = DateTime.MaxValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -79,9 +79,7 @@ namespace WebSocketSharp.Server
|
||||
/// </value>
|
||||
protected Logger Log {
|
||||
get {
|
||||
return _websocket != null
|
||||
? _websocket.Log
|
||||
: null;
|
||||
return _websocket != null ? _websocket.Log : null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,10 +101,10 @@ namespace WebSocketSharp.Server
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets the information in the current connection request to the WebSocket service.
|
||||
/// Gets the information in a connection request to the WebSocket service.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="WebSocketContext"/> that provides the access to the current connection request,
|
||||
/// A <see cref="WebSocketContext"/> that provides the access to the connection request,
|
||||
/// or <see langword="null"/> if the WebSocket connection isn't established.
|
||||
/// </value>
|
||||
public WebSocketContext Context {
|
||||
@ -116,12 +114,12 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the delegate called to validate the HTTP cookies included in a connection
|
||||
/// request to the WebSocket service.
|
||||
/// Gets or sets the delegate called to validate the HTTP cookies included in
|
||||
/// a connection request to the WebSocket service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The delegate is called when the <see cref="WebSocket"/> used in the current session
|
||||
/// validates the connection request.
|
||||
/// The delegate is called when the <see cref="WebSocket"/> used in the session validates
|
||||
/// the connection request.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// <para>
|
||||
@ -148,10 +146,10 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique ID of the current session.
|
||||
/// Gets the unique ID of a session.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="string"/> that represents the unique ID of the current session,
|
||||
/// A <see cref="string"/> that represents the unique ID of the session,
|
||||
/// or <see langword="null"/> if the WebSocket connection isn't established.
|
||||
/// </value>
|
||||
public string ID {
|
||||
@ -179,12 +177,12 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the delegate called to validate the Origin header included in a connection
|
||||
/// request to the WebSocket service.
|
||||
/// Gets or sets the delegate called to validate the Origin header included in
|
||||
/// a connection request to the WebSocket service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The delegate is called when the <see cref="WebSocket"/> used in the current session
|
||||
/// validates the connection request.
|
||||
/// The delegate is called when the <see cref="WebSocket"/> used in the session validates
|
||||
/// the connection request.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// <para>
|
||||
@ -210,7 +208,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the WebSocket subprotocol used in the current session.
|
||||
/// Gets or sets the WebSocket subprotocol used in the WebSocket service.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Set operation of this property is available before the WebSocket connection has been
|
||||
@ -228,9 +226,7 @@ namespace WebSocketSharp.Server
|
||||
/// </value>
|
||||
public string Protocol {
|
||||
get {
|
||||
return _websocket != null
|
||||
? _websocket.Protocol
|
||||
: _protocol ?? String.Empty;
|
||||
return _websocket != null ? _websocket.Protocol : (_protocol ?? String.Empty);
|
||||
}
|
||||
|
||||
set {
|
||||
@ -245,30 +241,28 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the time that the current session has started.
|
||||
/// Gets the time that a session has started.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// A <see cref="DateTime"/> that represents the time that the current session has started,
|
||||
/// A <see cref="DateTime"/> that represents the time that the session has started,
|
||||
/// or <see cref="DateTime.MaxValue"/> if the WebSocket connection isn't established.
|
||||
/// </value>
|
||||
public DateTime StartTime {
|
||||
get {
|
||||
return _start;
|
||||
return _startTime;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state of the <see cref="WebSocket"/> used in the current session.
|
||||
/// Gets the state of the <see cref="WebSocket"/> used in a session.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// One of the <see cref="WebSocketState"/> enum values, indicates the state of
|
||||
/// the <see cref="WebSocket"/> used in the current session.
|
||||
/// the <see cref="WebSocket"/> used in the session.
|
||||
/// </value>
|
||||
public WebSocketState State {
|
||||
get {
|
||||
return _websocket != null
|
||||
? _websocket.ReadyState
|
||||
: WebSocketState.Connecting;
|
||||
return _websocket != null ? _websocket.ReadyState : WebSocketState.Connecting;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +307,7 @@ namespace WebSocketSharp.Server
|
||||
return;
|
||||
}
|
||||
|
||||
_start = DateTime.Now;
|
||||
_startTime = DateTime.Now;
|
||||
OnOpen ();
|
||||
}
|
||||
|
||||
@ -375,7 +369,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the WebSocket connection used in the current session has been closed.
|
||||
/// Called when the WebSocket connection used in a session has been closed.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// A <see cref="CloseEventArgs"/> that represents the event data passed to
|
||||
@ -386,7 +380,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="WebSocket"/> used in the current session gets an error.
|
||||
/// Called when the <see cref="WebSocket"/> used in a session gets an error.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// A <see cref="ErrorEventArgs"/> that represents the event data passed to
|
||||
@ -397,7 +391,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the <see cref="WebSocket"/> used in the current session receives a message.
|
||||
/// Called when the <see cref="WebSocket"/> used in a session receives a message.
|
||||
/// </summary>
|
||||
/// <param name="e">
|
||||
/// A <see cref="MessageEventArgs"/> that represents the event data passed to
|
||||
@ -408,14 +402,14 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the WebSocket connection used in the current session has been established.
|
||||
/// Called when the WebSocket connection used in a session has been established.
|
||||
/// </summary>
|
||||
protected virtual void OnOpen ()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a binary <paramref name="data"/> to the client on the current session.
|
||||
/// Sends a binary <paramref name="data"/> to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is available after the WebSocket connection has been established.
|
||||
@ -430,8 +424,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends the specified <paramref name="file"/> as a binary data to the client
|
||||
/// on the current session.
|
||||
/// Sends the specified <paramref name="file"/> as a binary data to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is available after the WebSocket connection has been established.
|
||||
@ -446,7 +439,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a text <paramref name="data"/> to the client on the current session.
|
||||
/// Sends a text <paramref name="data"/> to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method is available after the WebSocket connection has been established.
|
||||
@ -461,7 +454,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a binary <paramref name="data"/> asynchronously to the client on the current session.
|
||||
/// Sends a binary <paramref name="data"/> asynchronously to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
@ -487,7 +480,7 @@ namespace WebSocketSharp.Server
|
||||
|
||||
/// <summary>
|
||||
/// Sends the specified <paramref name="file"/> as a binary data asynchronously
|
||||
/// to the client on the current session.
|
||||
/// to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
@ -512,7 +505,7 @@ namespace WebSocketSharp.Server
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a text <paramref name="data"/> asynchronously to the client on the current session.
|
||||
/// Sends a text <paramref name="data"/> asynchronously to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
@ -538,7 +531,7 @@ namespace WebSocketSharp.Server
|
||||
|
||||
/// <summary>
|
||||
/// Sends a binary data from the specified <see cref="Stream"/> asynchronously
|
||||
/// to the client on the current session.
|
||||
/// to the client on a session.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
|
Loading…
Reference in New Issue
Block a user