My Project
|
Provides the management function for the sessions in a WebSocket service. More...
Public Member Functions | |
void | Broadcast (byte[] data) |
Sends the specified data to every client in the WebSocket service. | |
void | Broadcast (string data) |
Sends the specified data to every client in the WebSocket service. | |
void | Broadcast (Stream stream, int length) |
Sends the data from the specified stream instance to every client in the WebSocket service. | |
void | BroadcastAsync (byte[] data, Action completed) |
Sends the specified data asynchronously to every client in the WebSocket service. | |
void | BroadcastAsync (string data, Action completed) |
Sends the specified data asynchronously to every client in the WebSocket service. | |
void | BroadcastAsync (Stream stream, int length, Action completed) |
Sends the data from the specified stream instance asynchronously to every client in the WebSocket service. | |
void | CloseSession (string id) |
Closes the session with the specified ID. | |
void | CloseSession (string id, ushort code, string reason) |
Closes the session with the specified ID, code, and reason. | |
void | CloseSession (string id, CloseStatusCode code, string reason) |
Closes the session with the specified ID, code, and reason. | |
bool | PingTo (string id) |
Sends a ping to the client using the specified session. | |
bool | PingTo (string message, string id) |
Sends a ping with the specified message to the client using the specified session. | |
void | SendTo (byte[] data, string id) |
Sends the specified data to the client using the specified session. | |
void | SendTo (string data, string id) |
Sends the specified data to the client using the specified session. | |
void | SendTo (Stream stream, int length, string id) |
Sends the data from the specified stream instance to the client using the specified session. | |
void | SendToAsync (byte[] data, string id, Action< bool > completed) |
Sends the specified data asynchronously to the client using the specified session. | |
void | SendToAsync (string data, string id, Action< bool > completed) |
Sends the specified data asynchronously to the client using the specified session. | |
void | SendToAsync (Stream stream, int length, string id, Action< bool > completed) |
Sends the data from the specified stream instance asynchronously to the client using the specified session. | |
void | Sweep () |
Cleans up the inactive sessions in the WebSocket service. | |
bool | TryGetSession (string id, out IWebSocketSession session) |
Tries to get the session instance with the specified ID. | |
Properties | |
IEnumerable< string > | ActiveIDs [get] |
Gets the IDs for the active sessions in the WebSocket service. | |
int | Count [get] |
Gets the number of the sessions in the WebSocket service. | |
IEnumerable< string > | IDs [get] |
Gets the IDs for the sessions in the WebSocket service. | |
IEnumerable< string > | InactiveIDs [get] |
Gets the IDs for the inactive sessions in the WebSocket service. | |
IWebSocketSession | this[string id] [get] |
Gets the session instance with the specified ID. | |
bool | KeepClean [get, set] |
Gets or sets a value indicating whether the inactive sessions in the WebSocket service are cleaned up periodically. | |
IEnumerable< IWebSocketSession > | Sessions [get] |
Gets the session instances in the WebSocket service. | |
TimeSpan | WaitTime [get, set] |
Gets or sets the time to wait for the response to the WebSocket Ping or Close. | |
Provides the management function for the sessions in a WebSocket service.
This class manages the sessions in a WebSocket service provided by the WebSocketServer or HttpServer class.
|
inline |
Sends the specified data to every client in the WebSocket service.
data | An array of byte that specifies the binary data to send. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | data is null . |
|
inline |
Sends the data from the specified stream instance to every client in the WebSocket service.
stream | A Stream instance from which to read the data to send. The data is sent as the binary data. |
length | An int that specifies the number of bytes to send. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | stream is null . |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
|
inline |
Sends the specified data to every client in the WebSocket service.
data | A string that specifies the text data to send. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | data is null . |
ArgumentException | data could not be UTF-8-encoded. |
|
inline |
Sends the specified data asynchronously to every client in the WebSocket service.
This method does not wait for the send to be complete.
data | An array of byte that specifies the binary data to send. |
completed | An Action delegate or null if not needed. The delegate invokes the method called when the send is complete. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | data is null . |
|
inline |
Sends the data from the specified stream instance asynchronously to every client in the WebSocket service.
This method does not wait for the send to be complete.
stream | A Stream instance from which to read the data to send. The data is sent as the binary data. |
length | An int that specifies the number of bytes to send. |
completed | An Action delegate or null if not needed. The delegate invokes the method called when the send is complete. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | stream is null . |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
|
inline |
Sends the specified data asynchronously to every client in the WebSocket service.
This method does not wait for the send to be complete.
data | A string that specifies the text data to send. |
completed | An Action delegate or null if not needed. The delegate invokes the method called when the send is complete. |
InvalidOperationException | The current state of the service is not Start. |
ArgumentNullException | data is null . |
ArgumentException | data could not be UTF-8-encoded. |
|
inline |
Closes the session with the specified ID.
id | A string that specifies the ID of the session to close. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. |
InvalidOperationException | The session could not be found. |
|
inline |
Closes the session with the specified ID, code, and reason.
id | A string that specifies the ID of the session to close. |
code | One of the CloseStatusCode enum values. It specifies the status code indicating the reason for the close. |
reason | A string that specifies the reason for the close. The size must be 123 bytes or less in UTF-8. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. -or- code is CloseStatusCode.MandatoryExtension. -or- code is CloseStatusCode.NoStatus and there is reason. -or- reason could not be UTF-8-encoded. |
InvalidOperationException | The session could not be found. |
ArgumentOutOfRangeException | The size of reason is greater than 123 bytes. |
|
inline |
Closes the session with the specified ID, code, and reason.
id | A string that specifies the ID of the session to close. |
code | A ushort that specifies the status code indicating the reason for the close. The status codes are defined in Section 7.4of RFC 6455. |
reason | A string that specifies the reason for the close. The size must be 123 bytes or less in UTF-8. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. -or- code is 1010 (mandatory extension). -or- code is 1005 (no status) and there is reason. -or- reason could not be UTF-8-encoded. |
InvalidOperationException | The session could not be found. |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
|
inline |
Sends a ping to the client using the specified session.
true
if the send has done with no error and a pong has been received from the client within a time; otherwise, false
. id | A string that specifies the ID of the session. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. |
InvalidOperationException | The session could not be found. |
|
inline |
Sends a ping with the specified message to the client using the specified session.
true
if the send has done with no error and a pong has been received from the client within a time; otherwise, false
. message | A string that specifies the message to send. The size must be 125 bytes or less in UTF-8. |
id | A string that specifies the ID of the session. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. -or- message could not be UTF-8-encoded. |
InvalidOperationException | The session could not be found. |
ArgumentOutOfRangeException | The size of message is greater than 125 bytes. |
|
inline |
Sends the specified data to the client using the specified session.
data | An array of byte that specifies the binary data to send. |
id | A string that specifies the ID of the session. |
ArgumentNullException | id is null . -or- data is null . |
ArgumentException | id is an empty string. |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Sends the data from the specified stream instance to the client using the specified session.
stream | A Stream instance from which to read the data to send. The data is sent as the binary data. |
length | An int that specifies the number of bytes to send. |
id | A string that specifies the ID of the session. |
ArgumentNullException | id is null . -or- stream is null . |
ArgumentException | id is an empty string. -or- stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Sends the specified data to the client using the specified session.
data | A string that specifies the text data to send. |
id | A string that specifies the ID of the session. |
ArgumentNullException | id is null . -or- data is null . |
ArgumentException | id is an empty string. -or- data could not be UTF-8-encoded. |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Sends the specified data asynchronously to the client using the specified session.
This method does not wait for the send to be complete.
data | An array of byte that specifies the binary data to send. |
id | A string that specifies the ID of the session. |
completed | An Action<bool> delegate or null if not needed. The delegate invokes the method called when the send is complete. true is passed to the method if the send has done with no error; otherwise, false . |
ArgumentNullException | id is null . -or- data is null . |
ArgumentException | id is an empty string. |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Sends the data from the specified stream instance asynchronously to the client using the specified session.
This method does not wait for the send to be complete.
stream | A Stream instance from which to read the data to send. The data is sent as the binary data. |
length | An int that specifies the number of bytes to send. |
id | A string that specifies the ID of the session. |
completed | An Action<bool> delegate or null if not needed. The delegate invokes the method called when the send is complete. true is passed to the method if the send has done with no error; otherwise, false . |
ArgumentNullException | id is null . -or- stream is null . |
ArgumentException | id is an empty string. -or- stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Sends the specified data asynchronously to the client using the specified session.
This method does not wait for the send to be complete.
data | A string that specifies the text data to send. |
id | A string that specifies the ID of the session. |
completed | An Action<bool> delegate or null if not needed. The delegate invokes the method called when the send is complete. true is passed to the method if the send has done with no error; otherwise, false . |
ArgumentNullException | id is null . -or- data is null . |
ArgumentException | id is an empty string. -or- data could not be UTF-8-encoded. |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket connection is not Open. |
|
inline |
Tries to get the session instance with the specified ID.
true
if the session is successfully found; otherwise, false
. id | A string that specifies the ID of the session to find. |
session | When this method returns, a IWebSocketSession instance or null if not found. The session instance provides the function to access the information in the session. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. |
|
get |
Gets the IDs for the active sessions in the WebSocket service.
An IEnumerable<string>
instance.
It provides an enumerator which supports the iteration over the collection of the IDs for the active sessions.
|
get |
Gets the number of the sessions in the WebSocket service.
An int that represents the number of the sessions.
|
get |
Gets the IDs for the sessions in the WebSocket service.
An IEnumerable<string>
instance.
It provides an enumerator which supports the iteration over the collection of the IDs for the sessions.
|
get |
Gets the IDs for the inactive sessions in the WebSocket service.
An IEnumerable<string>
instance.
It provides an enumerator which supports the iteration over the collection of the IDs for the inactive sessions.
|
getset |
Gets or sets a value indicating whether the inactive sessions in the WebSocket service are cleaned up periodically.
The set operation does nothing if the service has already started or it is shutting down.
true
if the inactive sessions are cleaned up every 60 seconds; otherwise, false
.
|
get |
Gets the session instances in the WebSocket service.
An IEnumerable<IWebSocketSession>
instance.
It provides an enumerator which supports the iteration over the collection of the session instances.
|
get |
Gets the session instance with the specified ID.
A IWebSocketSession instance or null
if not found.
The session instance provides the function to access the information in the session.
id | A string that specifies the ID of the session to find. |
ArgumentNullException | id is null . |
ArgumentException | id is an empty string. |
|
getset |
Gets or sets the time to wait for the response to the WebSocket Ping or Close.
The set operation does nothing if the service has already started or it is shutting down.
A TimeSpan to wait for the response.
ArgumentOutOfRangeException | The value specified for a set operation is zero or less. |