Refactored WebSocketSessionManager.cs

This commit is contained in:
sta 2014-02-12 16:13:50 +09:00
parent 76e95cf962
commit f69977a2fe

View File

@ -29,7 +29,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Timers; using System.Timers;
@ -37,7 +36,7 @@ using System.Timers;
namespace WebSocketSharp.Server namespace WebSocketSharp.Server
{ {
/// <summary> /// <summary>
/// Manages the sessions to a Websocket service. /// Manages the sessions in a Websocket service.
/// </summary> /// </summary>
public class WebSocketSessionManager public class WebSocketSessionManager
{ {
@ -83,10 +82,9 @@ namespace WebSocketSharp.Server
_keepClean = true; _keepClean = true;
_sessions = new Dictionary<string, IWebSocketSession> (); _sessions = new Dictionary<string, IWebSocketSession> ();
_state = ServerState.READY; _state = ServerState.READY;
_sweeping = false;
_sync = new object (); _sync = new object ();
setSweepTimer (60 * 1000); setSweepTimer (60000);
} }
#endregion #endregion
@ -104,23 +102,22 @@ namespace WebSocketSharp.Server
#region Public Properties #region Public Properties
/// <summary> /// <summary>
/// Gets the collection of every ID of the active sessions to the Websocket /// Gets the collection of every ID of the active sessions in the Websocket service.
/// service.
/// </summary> /// </summary>
/// <value> /// <value>
/// An IEnumerable&lt;string&gt; that contains the collection of every ID of /// An IEnumerable&lt;string&gt; that contains the collection of every ID of the active
/// the active sessions. /// sessions.
/// </value> /// </value>
public IEnumerable<string> ActiveIDs { public IEnumerable<string> ActiveIDs {
get { get {
return from result in Broadping (WsFrame.EmptyUnmaskPingData, 1000) foreach (var result in Broadping (WsFrame.EmptyUnmaskPingData, 1000))
where result.Value if (result.Value)
select result.Key; yield return result.Key;
} }
} }
/// <summary> /// <summary>
/// Gets the number of the sessions to the Websocket service. /// Gets the number of the sessions in the Websocket service.
/// </summary> /// </summary>
/// <value> /// <value>
/// An <see cref="int"/> that represents the number of the sessions. /// An <see cref="int"/> that represents the number of the sessions.
@ -134,46 +131,42 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Gets the collection of every ID of the sessions to the Websocket service. /// Gets the collection of every ID of the sessions in the Websocket service.
/// </summary> /// </summary>
/// <value> /// <value>
/// An IEnumerable&lt;string&gt; that contains the collection of every ID of /// An IEnumerable&lt;string&gt; that contains the collection of every ID of the sessions.
/// the sessions.
/// </value> /// </value>
public IEnumerable<string> IDs { public IEnumerable<string> IDs {
get { get {
lock (_sync) { return copySessions ().Keys;
return _sessions.Keys.ToList ();
}
} }
} }
/// <summary> /// <summary>
/// Gets the collection of every ID of the inactive sessions to the Websocket /// Gets the collection of every ID of the inactive sessions in the Websocket service.
/// service.
/// </summary> /// </summary>
/// <value> /// <value>
/// An IEnumerable&lt;string&gt; that contains the collection of every ID of /// An IEnumerable&lt;string&gt; that contains the collection of every ID of the inactive
/// the inactive sessions. /// sessions.
/// </value> /// </value>
public IEnumerable<string> InactiveIDs { public IEnumerable<string> InactiveIDs {
get { get {
return from result in Broadping (WsFrame.EmptyUnmaskPingData, 1000) foreach (var result in Broadping (WsFrame.EmptyUnmaskPingData, 1000))
where !result.Value if (!result.Value)
select result.Key; yield return result.Key;
} }
} }
/// <summary> /// <summary>
/// Gets a WebSocket session information with the specified <paramref name="id"/>. /// Gets a session information with the specified <paramref name="id"/> in the WebSocket
/// service.
/// </summary> /// </summary>
/// <value> /// <value>
/// A <see cref="IWebSocketSession"/> instance that represents the session if /// A <see cref="IWebSocketSession"/> instance that represents the session information if it's
/// it's successfully found; otherwise, <see langword="null"/>. /// successfully found; otherwise, <see langword="null"/>.
/// </value> /// </value>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the WebSocket session to /// A <see cref="string"/> that represents the ID of the session to find.
/// get.
/// </param> /// </param>
public IWebSocketSession this [string id] { public IWebSocketSession this [string id] {
get { get {
@ -185,12 +178,11 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Gets a value indicating whether the manager cleans up the inactive /// Gets a value indicating whether the manager cleans up the inactive sessions periodically.
/// sessions periodically.
/// </summary> /// </summary>
/// <value> /// <value>
/// <c>true</c> if the manager cleans up the inactive sessions every 60 /// <c>true</c> if the manager cleans up the inactive sessions every 60 seconds; otherwise,
/// seconds; otherwise, <c>false</c>. /// <c>false</c>.
/// </value> /// </value>
public bool KeepClean { public bool KeepClean {
get { get {
@ -208,20 +200,18 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Gets the collection of the session informations to the Websocket service. /// Gets the collection of the session informations in the Websocket service.
/// </summary> /// </summary>
/// <value> /// <value>
/// An IEnumerable&lt;IWebSocketSession&gt; that contains the collection of /// An IEnumerable&lt;IWebSocketSession&gt; that contains the collection of the session
/// the session informations to the Websocket service. /// informations.
/// </value> /// </value>
public IEnumerable<IWebSocketSession> Sessions { public IEnumerable<IWebSocketSession> Sessions {
get { get {
if (_state == ServerState.SHUTDOWN) if (_state == ServerState.SHUTDOWN)
return _emptySessions; return _emptySessions;
lock (_sync) { return copySessions ().Values;
return _sessions.Values.ToList ();
}
} }
} }
@ -276,9 +266,11 @@ namespace WebSocketSharp.Server
state => broadcast (opcode, stream, completed)); state => broadcast (opcode, stream, completed));
} }
private string checkIfCanSend (Func<string> checkParams) private Dictionary<string, IWebSocketSession> copySessions ()
{ {
return _state.CheckIfStart () ?? checkParams (); lock (_sync) {
return new Dictionary<string, IWebSocketSession> (_sessions);
}
} }
private static string createID () private static string createID ()
@ -300,8 +292,7 @@ namespace WebSocketSharp.Server
} }
if (!result) if (!result)
_logger.Error ( _logger.Error ("A session with the specified ID not found.\nID: " + id);
"A WebSocket session with the specified ID not found.\nID: " + id);
return result; return result;
} }
@ -345,8 +336,7 @@ namespace WebSocketSharp.Server
} }
} }
internal Dictionary<string, bool> Broadping ( internal Dictionary<string, bool> Broadping (byte [] frame, int millisecondsTimeout)
byte [] frameAsBytes, int timeOut)
{ {
var result = new Dictionary<string, bool> (); var result = new Dictionary<string, bool> ();
foreach (var session in Sessions) { foreach (var session in Sessions) {
@ -354,7 +344,7 @@ namespace WebSocketSharp.Server
break; break;
result.Add ( result.Add (
session.ID, session.Context.WebSocket.Ping (frameAsBytes, timeOut)); session.ID, session.Context.WebSocket.Ping (frame, millisecondsTimeout));
} }
return result; return result;
@ -377,22 +367,21 @@ namespace WebSocketSharp.Server
{ {
var payload = new PayloadData (data); var payload = new PayloadData (data);
var args = new CloseEventArgs (payload); var args = new CloseEventArgs (payload);
var frameAsBytes = var frameAsBytes = send
send ? WsFrame.CreateCloseFrame (Mask.UNMASK, payload).ToByteArray ()
? WsFrame.CreateCloseFrame (Mask.UNMASK, payload).ToByteArray () : null;
: null;
Stop (args, frameAsBytes); Stop (args, frameAsBytes);
} }
internal void Stop (CloseEventArgs args, byte [] frameAsBytes) internal void Stop (CloseEventArgs args, byte [] frame)
{ {
lock (_sync) { lock (_sync) {
_state = ServerState.SHUTDOWN; _state = ServerState.SHUTDOWN;
_sweepTimer.Enabled = false; _sweepTimer.Enabled = false;
foreach (var session in _sessions.Values.ToList ()) foreach (var session in copySessions ().Values)
session.Context.WebSocket.Close (args, frameAsBytes, 1000); session.Context.WebSocket.Close (args, frame, 1000);
_state = ServerState.STOP; _state = ServerState.STOP;
} }
@ -403,16 +392,14 @@ namespace WebSocketSharp.Server
#region Public Methods #region Public Methods
/// <summary> /// <summary>
/// Broadcasts a binary <paramref name="data"/> to all clients /// Broadcasts a binary <paramref name="data"/> to every client in the WebSocket service.
/// of the WebSocket service.
/// </summary> /// </summary>
/// <param name="data"> /// <param name="data">
/// An array of <see cref="byte"/> that represents the binary data /// An array of <see cref="byte"/> that represents the binary data to broadcast.
/// to broadcast.
/// </param> /// </param>
public void Broadcast (byte [] data) public void Broadcast (byte [] data)
{ {
var msg = checkIfCanSend (() => data.CheckIfValidSendData ()); var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData ();
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -425,15 +412,14 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Broadcasts a text <paramref name="data"/> to all clients /// Broadcasts a text <paramref name="data"/> to every client in the WebSocket service.
/// of the WebSocket service.
/// </summary> /// </summary>
/// <param name="data"> /// <param name="data">
/// A <see cref="string"/> that represents the text data to broadcast. /// A <see cref="string"/> that represents the text data to broadcast.
/// </param> /// </param>
public void Broadcast (string data) public void Broadcast (string data)
{ {
var msg = checkIfCanSend (() => data.CheckIfValidSendData ()); var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData ();
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -447,23 +433,22 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Broadcasts a binary <paramref name="data"/> asynchronously to all clients /// Broadcasts a binary <paramref name="data"/> asynchronously to every client in the WebSocket
/// of the WebSocket service. /// service.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the broadcast to be complete. /// This method doesn't wait for the broadcast to be complete.
/// </remarks> /// </remarks>
/// <param name="data"> /// <param name="data">
/// An array of <see cref="byte"/> that represents the binary data /// An array of <see cref="byte"/> that represents the binary data to broadcast.
/// to broadcast.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// A <see cref="Action"/> delegate that references the method(s) called when /// A <see cref="Action"/> delegate that references the method(s) called when the broadcast is
/// the broadcast is complete. /// complete.
/// </param> /// </param>
public void BroadcastAsync (byte [] data, Action completed) public void BroadcastAsync (byte [] data, Action completed)
{ {
var msg = checkIfCanSend (() => data.CheckIfValidSendData ()); var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData ();
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -476,8 +461,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Broadcasts a text <paramref name="data"/> asynchronously to all clients /// Broadcasts a text <paramref name="data"/> asynchronously to every client in the WebSocket
/// of the WebSocket service. /// service.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the broadcast to be complete. /// This method doesn't wait for the broadcast to be complete.
@ -486,12 +471,12 @@ namespace WebSocketSharp.Server
/// A <see cref="string"/> that represents the text data to broadcast. /// A <see cref="string"/> that represents the text data to broadcast.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// A <see cref="Action"/> delegate that references the method(s) called when /// A <see cref="Action"/> delegate that references the method(s) called when the broadcast is
/// the broadcast is complete. /// complete.
/// </param> /// </param>
public void BroadcastAsync (string data, Action completed) public void BroadcastAsync (string data, Action completed)
{ {
var msg = checkIfCanSend (() => data.CheckIfValidSendData ()); var msg = _state.CheckIfStart () ?? data.CheckIfValidSendData ();
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
return; return;
@ -505,8 +490,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Broadcasts a binary data from the specified <see cref="Stream"/> /// Broadcasts a binary data from the specified <see cref="Stream"/> asynchronously to every
/// asynchronously to all clients of the WebSocket service. /// client in the WebSocket service.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the broadcast to be complete. /// This method doesn't wait for the broadcast to be complete.
@ -518,14 +503,14 @@ namespace WebSocketSharp.Server
/// An <see cref="int"/> that represents the number of bytes to broadcast. /// An <see cref="int"/> that represents the number of bytes to broadcast.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// A <see cref="Action"/> delegate that references the method(s) called when /// A <see cref="Action"/> delegate that references the method(s) called when the broadcast is
/// the broadcast is complete. /// complete.
/// </param> /// </param>
public void BroadcastAsync (Stream stream, int length, Action completed) public void BroadcastAsync (Stream stream, int length, Action completed)
{ {
var msg = checkIfCanSend ( var msg = _state.CheckIfStart () ??
() => stream.CheckIfCanRead () ?? stream.CheckIfCanRead () ??
(length < 1 ? "'length' must be greater than 0." : null)); (length < 1 ? "'length' must be greater than 0." : null);
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
@ -557,12 +542,11 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends Pings to all clients of the WebSocket service. /// Sends a Ping to every client in the WebSocket service.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A Dictionary&lt;string, bool&gt; that contains the collection of pairs of /// A Dictionary&lt;string, bool&gt; that contains the collection of pairs of session ID and
/// session ID and value indicating whether the WebSocket service received a /// value indicating whether the manager received a Pong from every client in a time.
/// Pong from each client in a time.
/// </returns> /// </returns>
public Dictionary<string, bool> Broadping () public Dictionary<string, bool> Broadping ()
{ {
@ -576,13 +560,12 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends Pings with the specified <paramref name="message"/> to all clients /// Sends a Ping with the specified <paramref name="message"/> to every client in the WebSocket
/// of the WebSocket service. /// service.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// A Dictionary&lt;string, bool&gt; that contains the collection of pairs of /// A Dictionary&lt;string, bool&gt; that contains the collection of pairs of session ID and
/// session ID and value indicating whether the WebSocket service received a /// value indicating whether the manager received a Pong from every client in a time.
/// Pong from each client in a time.
/// </returns> /// </returns>
/// <param name="message"> /// <param name="message">
/// A <see cref="string"/> that represents the message to send. /// A <see cref="string"/> that represents the message to send.
@ -593,9 +576,8 @@ namespace WebSocketSharp.Server
return Broadping (); return Broadping ();
byte [] data = null; byte [] data = null;
var msg = checkIfCanSend ( var msg = _state.CheckIfStart () ??
() => (data = Encoding.UTF8.GetBytes (message)) (data = Encoding.UTF8.GetBytes (message)).CheckIfValidControlData ("message");
.CheckIfValidControlData ("message"));
if (msg != null) { if (msg != null) {
_logger.Error (msg); _logger.Error (msg);
@ -620,14 +602,14 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Closes the session with the specified <paramref name="id"/>, /// Closes the session with the specified <paramref name="id"/>, <paramref name="code"/>, and
/// <paramref name="code"/> and <paramref name="reason"/>. /// <paramref name="reason"/>.
/// </summary> /// </summary>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to close. /// A <see cref="string"/> that represents the ID of the session to close.
/// </param> /// </param>
/// <param name="code"> /// <param name="code">
/// A <see cref="ushort"/> that represents the status code for closure. /// A <see cref="ushort"/> that indicates the status code for closure.
/// </param> /// </param>
/// <param name="reason"> /// <param name="reason">
/// A <see cref="string"/> that represents the reason for closure. /// A <see cref="string"/> that represents the reason for closure.
@ -640,15 +622,15 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Closes the session with the specified <paramref name="id"/>, /// Closes the session with the specified <paramref name="id"/>, <paramref name="code"/>, and
/// <paramref name="code"/> and <paramref name="reason"/>. /// <paramref name="reason"/>.
/// </summary> /// </summary>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to close. /// A <see cref="string"/> that represents the ID of the session to close.
/// </param> /// </param>
/// <param name="code"> /// <param name="code">
/// One of the <see cref="CloseStatusCode"/> values that indicate the status /// One of the <see cref="CloseStatusCode"/> enum values, indicates the status code for
/// codes for closure. /// closure.
/// </param> /// </param>
/// <param name="reason"> /// <param name="reason">
/// A <see cref="string"/> that represents the reason for closure. /// A <see cref="string"/> that represents the reason for closure.
@ -661,16 +643,14 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a Ping to the client associated with the specified /// Sends a Ping to the client on the session with the specified <paramref name="id"/>.
/// <paramref name="id"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if the WebSocket service receives a Pong from the client in a /// <c>true</c> if the manager receives a Pong from the client in a time; otherwise,
/// time; otherwise, <c>false</c>. /// <c>false</c>.
/// </returns> /// </returns>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to send the /// A <see cref="string"/> that represents the ID of the session to find.
/// Ping to.
/// </param> /// </param>
public bool PingTo (string id) public bool PingTo (string id)
{ {
@ -680,16 +660,15 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a Ping with the specified <paramref name="message"/> to the client /// Sends a Ping with the specified <paramref name="message"/> to the client on the session
/// associated with the specified <paramref name="id"/>. /// with the specified <paramref name="id"/>.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if the WebSocket service receives a Pong from the client in a /// <c>true</c> if the manager receives a Pong from the client in a time; otherwise,
/// time; otherwise, <c>false</c>. /// <c>false</c>.
/// </returns> /// </returns>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to send the /// A <see cref="string"/> that represents the ID of the session to find.
/// Ping to.
/// </param> /// </param>
/// <param name="message"> /// <param name="message">
/// A <see cref="string"/> that represents the message to send. /// A <see cref="string"/> that represents the message to send.
@ -702,8 +681,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a binary <paramref name="data"/> to the client on the session /// Sends a binary <paramref name="data"/> to the client on the session with the specified
/// with the specified <paramref name="id"/>. /// <paramref name="id"/>.
/// </summary> /// </summary>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to find. /// A <see cref="string"/> that represents the ID of the session to find.
@ -719,12 +698,11 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a text <paramref name="data"/> to the client on the session /// Sends a text <paramref name="data"/> to the client on the session with the specified
/// with the specified <paramref name="id"/>. /// <paramref name="id"/>.
/// </summary> /// </summary>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to find. /// A <see cref="string"/> that represents the ID of the session to find.
/// data to.
/// </param> /// </param>
/// <param name="data"> /// <param name="data">
/// A <see cref="string"/> that represents the text data to send. /// A <see cref="string"/> that represents the text data to send.
@ -737,8 +715,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a binary <paramref name="data"/> asynchronously to the client /// Sends a binary <paramref name="data"/> asynchronously to the client on the session with the
/// on the session with the specified <paramref name="id"/>. /// specified <paramref name="id"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the send to be complete. /// This method doesn't wait for the send to be complete.
@ -750,9 +728,8 @@ namespace WebSocketSharp.Server
/// An array of <see cref="byte"/> that represents the binary data to send. /// An array of <see cref="byte"/> that represents the binary data to send.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// An Action&lt;bool&gt; delegate that references the method(s) called when /// An Action&lt;bool&gt; delegate that references the method(s) called when the send is
/// the send is complete. /// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// complete successfully; otherwise, <c>false</c>. /// complete successfully; otherwise, <c>false</c>.
/// </param> /// </param>
public void SendToAsync (string id, byte [] data, Action<bool> completed) public void SendToAsync (string id, byte [] data, Action<bool> completed)
@ -763,8 +740,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a text <paramref name="data"/> asynchronously to the client /// Sends a text <paramref name="data"/> asynchronously to the client on the session with the
/// on the session with the specified <paramref name="id"/>. /// specified <paramref name="id"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the send to be complete. /// This method doesn't wait for the send to be complete.
@ -776,9 +753,8 @@ namespace WebSocketSharp.Server
/// A <see cref="string"/> that represents the text data to send. /// A <see cref="string"/> that represents the text data to send.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// An Action&lt;bool&gt; delegate that references the method(s) called when /// An Action&lt;bool&gt; delegate that references the method(s) called when the send is
/// the send is complete. /// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// complete successfully; otherwise, <c>false</c>. /// complete successfully; otherwise, <c>false</c>.
/// </param> /// </param>
public void SendToAsync (string id, string data, Action<bool> completed) public void SendToAsync (string id, string data, Action<bool> completed)
@ -789,8 +765,8 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Sends a binary data from the specified <see cref="Stream"/> asynchronously /// Sends a binary data from the specified <see cref="Stream"/> asynchronously to the client on
/// to the client on the session with the specified <paramref name="id"/>. /// the session with the specified <paramref name="id"/>.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method doesn't wait for the send to be complete. /// This method doesn't wait for the send to be complete.
@ -805,9 +781,8 @@ namespace WebSocketSharp.Server
/// An <see cref="int"/> that represents the number of bytes to send. /// An <see cref="int"/> that represents the number of bytes to send.
/// </param> /// </param>
/// <param name="completed"> /// <param name="completed">
/// An Action&lt;bool&gt; delegate that references the method(s) called when /// An Action&lt;bool&gt; delegate that references the method(s) called when the send is
/// the send is complete. /// complete. A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// A <see cref="bool"/> passed to this delegate is <c>true</c> if the send is
/// complete successfully; otherwise, <c>false</c>. /// complete successfully; otherwise, <c>false</c>.
/// </param> /// </param>
public void SendToAsync ( public void SendToAsync (
@ -819,7 +794,7 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Cleans up the inactive sessions. /// Cleans up the inactive sessions in the WebSocket service.
/// </summary> /// </summary>
public void Sweep () public void Sweep ()
{ {
@ -851,19 +826,19 @@ namespace WebSocketSharp.Server
} }
/// <summary> /// <summary>
/// Tries to get a WebSocket session information with the specified /// Tries to get a session information with the specified <paramref name="id"/> in the
/// <paramref name="id"/>. /// WebSocket service.
/// </summary> /// </summary>
/// <returns> /// <returns>
/// <c>true</c> if the session is successfully found; otherwise, <c>false</c>. /// <c>true</c> if the session is successfully found; otherwise, <c>false</c>.
/// </returns> /// </returns>
/// <param name="id"> /// <param name="id">
/// A <see cref="string"/> that represents the ID of the session to get. /// A <see cref="string"/> that represents the ID of the session to find.
/// </param> /// </param>
/// <param name="session"> /// <param name="session">
/// When this method returns, a <see cref="IWebSocketSession"/> instance that /// When this method returns, a <see cref="IWebSocketSession"/> instance that represents the
/// represents the session if it's successfully found; otherwise, /// session information if it's successfully found; otherwise, <see langword="null"/>. This
/// <see langword="null"/>. This parameter is passed uninitialized. /// parameter is passed uninitialized.
/// </param> /// </param>
public bool TryGetSession (string id, out IWebSocketSession session) public bool TryGetSession (string id, out IWebSocketSession session)
{ {