SkyWay Unity SDK
公式APIリファレンス
|
Provides the management function for the sessions in a WebSocket service. [詳解]
公開メンバ関数 | |
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 to every client in the WebSocket service asynchronously. | |
void | BroadcastAsync (string data, Action completed) |
Sends the specified data to every client in the WebSocket service asynchronously. | |
void | BroadcastAsync (Stream stream, int length, Action completed) |
Sends the data from the specified stream instance to every client in the WebSocket service asynchronously. | |
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, status code, and reason. | |
void | CloseSession (string id, CloseStatusCode code, string reason) |
Closes the session with the specified ID, status 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 to the client using the specified session asynchronously. | |
void | SendToAsync (string data, string id, Action< bool > completed) |
Sends the specified data to the client using the specified session asynchronously. | |
void | SendToAsync (Stream stream, int length, string id, Action< bool > completed) |
Sends the data from the specified stream instance to the client using the specified session asynchronously. | |
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. | |
プロパティ | |
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. |
ArgumentNullException | data is null . |
InvalidOperationException | The current state of the service is not Start. |
|
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. |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
ArgumentNullException | stream is null . |
InvalidOperationException | The current state of the service is not Start. |
|
inline |
Sends the specified data to every client in the WebSocket service.
data | A string that specifies the text data to send. |
ArgumentException | data could not be UTF-8-encoded. |
ArgumentNullException | data is null . |
InvalidOperationException | The current state of the service is not Start. |
|
inline |
Sends the specified data to every client in the WebSocket service asynchronously.
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. It specifies the delegate called when the send is complete. null if not necessary. |
ArgumentNullException | data is null . |
InvalidOperationException | The current state of the service is not Start. |
|
inline |
Sends the data from the specified stream instance to every client in the WebSocket service asynchronously.
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. It specifies the delegate called when the send is complete. null if not necessary. |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
ArgumentNullException | stream is null . |
InvalidOperationException | The current state of the service is not Start. |
|
inline |
Sends the specified data to every client in the WebSocket service asynchronously.
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. It specifies the delegate called when the send is complete. null if not necessary. |
ArgumentException | data could not be UTF-8-encoded. |
ArgumentNullException | data is null . |
InvalidOperationException | The current state of the service is not Start. |
|
inline |
Closes the session with the specified ID.
id | A string that specifies the ID of the session to close. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . |
InvalidOperationException | The session could not be found. |
|
inline |
Closes the session with the specified ID, status 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. Its size must be 123 bytes or less in UTF-8. |
ArgumentException | id is an empty string. -or- code is an undefined enum value. -or- code is CloseStatusCode.MandatoryExtension. -or- code is CloseStatusCode.NoStatus and reason is specified. -or- reason could not be UTF-8-encoded. |
ArgumentNullException | id is null . |
ArgumentOutOfRangeException | The size of reason is greater than 123 bytes. |
InvalidOperationException | The session could not be found. |
|
inline |
Closes the session with the specified ID, status 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. Its size must be 123 bytes or less in UTF-8. |
ArgumentException | id is an empty string. -or- code is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded. |
ArgumentNullException | id is null . |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
InvalidOperationException | The session could not be found. |
|
inline |
Sends a ping to the client using the specified session.
true
if the send has successfully done and a pong has been received within a time; otherwise, false
. id | A string that specifies the ID of the session. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . |
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 successfully done and a pong has been received within a time; otherwise, false
. message | A string that specifies the message to send. Its size must be 125 bytes or less in UTF-8. |
id | A string that specifies the ID of the session. |
ArgumentException | id is an empty string. -or- message could not be UTF-8-encoded. |
ArgumentNullException | id is null . |
ArgumentOutOfRangeException | The size of message is greater than 125 bytes. |
InvalidOperationException | The session could not be found. |
|
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. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . -or- data is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface 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. |
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 . |
ArgumentNullException | id is null . -or- stream is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface 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. |
ArgumentException | id is an empty string. -or- data could not be UTF-8-encoded. |
ArgumentNullException | id is null . -or- data is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface is not Open. |
|
inline |
Sends the specified data to the client using the specified session asynchronously.
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 T:System.Action<bool> delegate. It specifies the delegate called when the send is complete. The bool parameter passed to the delegate is true if the send has successfully done; otherwise, false . null if not necessary. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . -or- data is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface is not Open. |
|
inline |
Sends the data from the specified stream instance to the client using the specified session asynchronously.
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 T:System.Action<bool> delegate. It specifies the delegate called when the send is complete. The bool parameter passed to the delegate is true if the send has successfully done; otherwise, false . null if not necessary. |
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 . |
ArgumentNullException | id is null . -or- stream is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface is not Open. |
|
inline |
Sends the specified data to the client using the specified session asynchronously.
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 T:System.Action<bool> delegate. It specifies the delegate called when the send is complete. The bool parameter passed to the delegate is true if the send has successfully done; otherwise, false . null if not necessary. |
ArgumentException | id is an empty string. -or- data could not be UTF-8-encoded. |
ArgumentNullException | id is null . -or- data is null . |
InvalidOperationException | The session could not be found. -or- The current state of the WebSocket interface is not Open. |
|
inline |
Tries to get the session instance with the specified ID.
true
if the try has succeeded; otherwise, false
. id | A string that specifies the ID of the session to get. |
session | When this method returns, a IWebSocketSession instance that receives the session instance. It provides the function to access the information in the session. null if not found. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . |
|
get |
Gets the IDs for the active sessions in the WebSocket service.
An T:System.Collections.Generic.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 T:System.Collections.Generic.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 T:System.Collections.Generic.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 works if the current state of the service is Ready or Stop.
true
if the inactive sessions are cleaned up every 60 seconds; otherwise, false
.
|
get |
Gets the session instances in the WebSocket service.
An T:System.Collections.Generic.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 that provides the function to access the information in the session.
null
if not found.
id | A string that specifies the ID of the session to get. |
ArgumentException | id is an empty string. |
ArgumentNullException | id is null . |
|
getset |
Gets or sets the time to wait for the response to the WebSocket Ping or Close.
The set operation works if the current state of the service is Ready or Stop.
A TimeSpan that represents the time to wait for the response.
ArgumentOutOfRangeException | The value specified for a set operation is zero or less. |