SkyWay Unity SDK
公式APIリファレンス
読み取り中…
検索中…
一致する文字列を見つけられません
WebSocketSharp.Server.WebSocketSessionManager クラス

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< IWebSocketSessionSessions [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.

関数詳解

◆ Broadcast() [1/3]

void WebSocketSharp.Server.WebSocketSessionManager.Broadcast ( byte[] data)
inline

Sends the specified data to every client in the WebSocket service.

引数
dataAn array of byte that specifies the binary data to send.
例外
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ Broadcast() [2/3]

void WebSocketSharp.Server.WebSocketSessionManager.Broadcast ( Stream stream,
int length )
inline

Sends the data from the specified stream instance to every client in the WebSocket service.

引数
streamA Stream instance from which to read the data to send. The data is sent as the binary data.
lengthAn int that specifies the number of bytes to send.
例外
ArgumentExceptionstream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionstream is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ Broadcast() [3/3]

void WebSocketSharp.Server.WebSocketSessionManager.Broadcast ( string data)
inline

Sends the specified data to every client in the WebSocket service.

引数
dataA string that specifies the text data to send.
例外
ArgumentExceptiondata could not be UTF-8-encoded.
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ BroadcastAsync() [1/3]

void WebSocketSharp.Server.WebSocketSessionManager.BroadcastAsync ( byte[] data,
Action completed )
inline

Sends the specified data to every client in the WebSocket service asynchronously.

This method does not wait for the send to be complete.

引数
dataAn array of byte that specifies the binary data to send.
completedAn Action delegate. It specifies the delegate called when the send is complete. null if not necessary.
例外
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ BroadcastAsync() [2/3]

void WebSocketSharp.Server.WebSocketSessionManager.BroadcastAsync ( Stream stream,
int length,
Action completed )
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.

引数
streamA Stream instance from which to read the data to send. The data is sent as the binary data.
lengthAn int that specifies the number of bytes to send.
completedAn Action delegate. It specifies the delegate called when the send is complete. null if not necessary.
例外
ArgumentExceptionstream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionstream is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ BroadcastAsync() [3/3]

void WebSocketSharp.Server.WebSocketSessionManager.BroadcastAsync ( string data,
Action completed )
inline

Sends the specified data to every client in the WebSocket service asynchronously.

This method does not wait for the send to be complete.

引数
dataA string that specifies the text data to send.
completedAn Action delegate. It specifies the delegate called when the send is complete. null if not necessary.
例外
ArgumentExceptiondata could not be UTF-8-encoded.
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe current state of the service is not Start.

◆ CloseSession() [1/3]

void WebSocketSharp.Server.WebSocketSessionManager.CloseSession ( string id)
inline

Closes the session with the specified ID.

引数
idA string that specifies the ID of the session to close.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null.
InvalidOperationExceptionThe session could not be found.

◆ CloseSession() [2/3]

void WebSocketSharp.Server.WebSocketSessionManager.CloseSession ( string id,
CloseStatusCode code,
string reason )
inline

Closes the session with the specified ID, status code, and reason.

引数
idA string that specifies the ID of the session to close.
codeOne of the CloseStatusCode enum values. It specifies the status code indicating the reason for the close.
reasonA string that specifies the reason for the close. Its size must be 123 bytes or less in UTF-8.
例外
ArgumentExceptionid 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.
ArgumentNullExceptionid is null.
ArgumentOutOfRangeExceptionThe size of reason is greater than 123 bytes.
InvalidOperationExceptionThe session could not be found.

◆ CloseSession() [3/3]

void WebSocketSharp.Server.WebSocketSessionManager.CloseSession ( string id,
ushort code,
string reason )
inline

Closes the session with the specified ID, status code, and reason.

引数
idA string that specifies the ID of the session to close.
codeA ushort that specifies the status code indicating the reason for the close. The status codes are defined in Section 7.4of RFC 6455.
reasonA string that specifies the reason for the close. Its size must be 123 bytes or less in UTF-8.
例外
ArgumentExceptionid 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.
ArgumentNullExceptionid is null.
ArgumentOutOfRangeExceptioncode is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes.
InvalidOperationExceptionThe session could not be found.

◆ PingTo() [1/2]

bool WebSocketSharp.Server.WebSocketSessionManager.PingTo ( string id)
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.
引数
idA string that specifies the ID of the session.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null.
InvalidOperationExceptionThe session could not be found.

◆ PingTo() [2/2]

bool WebSocketSharp.Server.WebSocketSessionManager.PingTo ( string message,
string id )
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.
引数
messageA string that specifies the message to send. Its size must be 125 bytes or less in UTF-8.
idA string that specifies the ID of the session.
例外
ArgumentExceptionid is an empty string. -or- message could not be UTF-8-encoded.
ArgumentNullExceptionid is null.
ArgumentOutOfRangeExceptionThe size of message is greater than 125 bytes.
InvalidOperationExceptionThe session could not be found.

◆ SendTo() [1/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendTo ( byte[] data,
string id )
inline

Sends the specified data to the client using the specified session.

引数
dataAn array of byte that specifies the binary data to send.
idA string that specifies the ID of the session.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null. -or- data is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ SendTo() [2/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendTo ( Stream stream,
int length,
string id )
inline

Sends the data from the specified stream instance to the client using the specified session.

引数
streamA Stream instance from which to read the data to send. The data is sent as the binary data.
lengthAn int that specifies the number of bytes to send.
idA string that specifies the ID of the session.
例外
ArgumentExceptionid is an empty string. -or- stream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionid is null. -or- stream is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ SendTo() [3/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendTo ( string data,
string id )
inline

Sends the specified data to the client using the specified session.

引数
dataA string that specifies the text data to send.
idA string that specifies the ID of the session.
例外
ArgumentExceptionid is an empty string. -or- data could not be UTF-8-encoded.
ArgumentNullExceptionid is null. -or- data is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ SendToAsync() [1/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendToAsync ( byte[] data,
string id,
Action< bool > completed )
inline

Sends the specified data to the client using the specified session asynchronously.

This method does not wait for the send to be complete.

引数
dataAn array of byte that specifies the binary data to send.
idA string that specifies the ID of the session.
completedAn 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.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null. -or- data is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ SendToAsync() [2/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendToAsync ( Stream stream,
int length,
string id,
Action< bool > completed )
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.

引数
streamA Stream instance from which to read the data to send. The data is sent as the binary data.
lengthAn int that specifies the number of bytes to send.
idA string that specifies the ID of the session.
completedAn 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.
例外
ArgumentExceptionid is an empty string. -or- stream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionid is null. -or- stream is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ SendToAsync() [3/3]

void WebSocketSharp.Server.WebSocketSessionManager.SendToAsync ( string data,
string id,
Action< bool > completed )
inline

Sends the specified data to the client using the specified session asynchronously.

This method does not wait for the send to be complete.

引数
dataA string that specifies the text data to send.
idA string that specifies the ID of the session.
completedAn 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.
例外
ArgumentExceptionid is an empty string. -or- data could not be UTF-8-encoded.
ArgumentNullExceptionid is null. -or- data is null.
InvalidOperationExceptionThe session could not be found. -or- The current state of the WebSocket interface is not Open.

◆ TryGetSession()

bool WebSocketSharp.Server.WebSocketSessionManager.TryGetSession ( string id,
out IWebSocketSession session )
inline

Tries to get the session instance with the specified ID.

戻り値
true if the try has succeeded; otherwise, false.
引数
idA string that specifies the ID of the session to get.
sessionWhen 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.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null.

プロパティ詳解

◆ ActiveIDs

IEnumerable<string> WebSocketSharp.Server.WebSocketSessionManager.ActiveIDs
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.

◆ Count

int WebSocketSharp.Server.WebSocketSessionManager.Count
get

Gets the number of the sessions in the WebSocket service.

An int that represents the number of the sessions.

◆ IDs

IEnumerable<string> WebSocketSharp.Server.WebSocketSessionManager.IDs
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.

◆ InactiveIDs

IEnumerable<string> WebSocketSharp.Server.WebSocketSessionManager.InactiveIDs
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.

◆ KeepClean

bool WebSocketSharp.Server.WebSocketSessionManager.KeepClean
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.

◆ Sessions

IEnumerable<IWebSocketSession> WebSocketSharp.Server.WebSocketSessionManager.Sessions
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.

◆ this[string id]

IWebSocketSession WebSocketSharp.Server.WebSocketSessionManager.this[string id]
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.

引数
idA string that specifies the ID of the session to get.
例外
ArgumentExceptionid is an empty string.
ArgumentNullExceptionid is null.

◆ WaitTime

TimeSpan WebSocketSharp.Server.WebSocketSessionManager.WaitTime
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.

例外
ArgumentOutOfRangeExceptionThe value specified for a set operation is zero or less.

このクラス詳解は次のファイルから抽出されました: