SkyWay Unity SDK
公式APIリファレンス
|
Exposes a set of methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or HttpServer class. [詳解]
限定公開メンバ関数 | |
WebSocketBehavior () | |
Initializes a new instance of the WebSocketBehavior class. | |
void | Close () |
Closes the WebSocket connection for a session. | |
void | Close (ushort code, string reason) |
Closes the WebSocket connection for a session with the specified status code and reason. | |
void | Close (CloseStatusCode code, string reason) |
Closes the WebSocket connection for a session with the specified status code and reason. | |
void | CloseAsync () |
Closes the WebSocket connection for a session asynchronously. | |
void | CloseAsync (ushort code, string reason) |
Closes the WebSocket connection for a session asynchronously with the specified status code and reason. | |
void | CloseAsync (CloseStatusCode code, string reason) |
Closes the WebSocket connection for a session asynchronously with the specified status code and reason. | |
virtual void | OnClose (CloseEventArgs e) |
Called when the WebSocket connection for a session has been closed. | |
virtual void | OnError (ErrorEventArgs e) |
Called when the WebSocket interface for a session gets an error. | |
virtual void | OnMessage (MessageEventArgs e) |
Called when the WebSocket interface for a session receives a message. | |
virtual void | OnOpen () |
Called when the WebSocket connection for a session has been established. | |
bool | Ping () |
Sends a ping to the client for a session. | |
bool | Ping (string message) |
Sends a ping with the specified message to the client for a session. | |
void | Send (byte[] data) |
Sends the specified data to the client for a session. | |
void | Send (FileInfo fileInfo) |
Sends the specified file to the client for a session. | |
void | Send (string data) |
Sends the specified data to the client for a session. | |
void | Send (Stream stream, int length) |
Sends the data from the specified stream instance to the client for a session. | |
void | SendAsync (byte[] data, Action< bool > completed) |
Sends the specified data to the client for a session asynchronously. | |
void | SendAsync (FileInfo fileInfo, Action< bool > completed) |
Sends the specified file to the client for a session asynchronously. | |
void | SendAsync (string data, Action< bool > completed) |
Sends the specified data to the client for a session asynchronously. | |
void | SendAsync (Stream stream, int length, Action< bool > completed) |
Sends the data from the specified stream instance to the client for a session asynchronously. | |
プロパティ | |
NameValueCollection | Headers [get] |
Gets the HTTP headers for a session. | |
bool | IsAlive [get] |
Gets a value indicating whether the communication is possible for a session. | |
NameValueCollection | QueryString [get] |
Gets the query string for a session. | |
WebSocketState | ReadyState [get] |
Gets the current state of the WebSocket interface for a session. | |
WebSocketSessionManager | Sessions [get] |
Gets the management function for the sessions in the service. | |
IPrincipal | User [get] |
Gets the client information for a session. | |
System.Net.IPEndPoint | UserEndPoint [get] |
Gets the client endpoint for a session. | |
Action< CookieCollection, CookieCollection > | CookiesResponder [get, set] |
Gets or sets the delegate used to respond to the HTTP cookies. | |
bool | EmitOnPing [get, set] |
Gets or sets a value indicating whether the WebSocket interface for a session emits the message event when it receives a ping. | |
Func< string, bool > | HostValidator [get, set] |
Gets or sets the delegate used to validate the Host header. | |
string | ID [get] |
Gets the unique ID of a session. | |
bool | IgnoreExtensions [get, set] |
Gets or sets a value indicating whether the WebSocket interface for a session ignores the Sec-WebSocket-Extensions header. | |
bool | NoDelay [get, set] |
Gets or sets a value indicating whether the underlying TCP socket of the WebSocket interface for a session disables a delay when send or receive buffer is not full. | |
Func< string, bool > | OriginValidator [get, set] |
Gets or sets the delegate used to validate the Origin header. | |
string | Protocol [get, set] |
Gets or sets the name of the WebSocket subprotocol for a session. | |
DateTime | StartTime [get] |
Gets the time that a session has started. | |
Action< NameValueCollection, WebHeaderCollection > | UserHeadersResponder [get, set] |
Gets or sets the delegate used to respond to the user headers. | |
![]() |
Exposes a set of methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or HttpServer class.
This class is an abstract class.
|
inlineprotected |
|
inlineprotected |
Closes the WebSocket connection for a session with the specified status code and reason.
This method does nothing when the current state of the WebSocket interface is Closing or Closed.
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 | 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. |
ArgumentOutOfRangeException | The size of reason is greater than 123 bytes. |
InvalidOperationException | The Close method is not available when the session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session with the specified status code and reason.
This method does nothing when the current state of the WebSocket interface is Closing or Closed.
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 | code is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded. |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
InvalidOperationException | The Close method is not available when the session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously.
This method does not wait for the close to be complete.
This method does nothing when the current state of the WebSocket interface is Closing or Closed.
InvalidOperationException | The CloseAsync method is not available when the session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously with the specified status code and reason.
This method does not wait for the close to be complete.
This method does nothing when the current state of the WebSocket interface is Closing or Closed.
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 | 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. |
ArgumentOutOfRangeException | The size of reason is greater than 123 bytes. |
InvalidOperationException | The CloseAsync method is not available when the session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously with the specified status code and reason.
This method does not wait for the close to be complete.
This method does nothing when the current state of the WebSocket interface is Closing or Closed.
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 | code is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded. |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
InvalidOperationException | The CloseAsync method is not available when the session has not started yet. |
|
inlineprotectedvirtual |
Called when the WebSocket connection for a session has been closed.
e | A CloseEventArgs that represents the event data passed from a WebSocket.OnClose event. |
|
inlineprotectedvirtual |
Called when the WebSocket interface for a session gets an error.
e | A ErrorEventArgs that represents the event data passed from a WebSocket.OnError event. |
|
inlineprotectedvirtual |
Called when the WebSocket interface for a session receives a message.
e | A MessageEventArgs that represents the event data passed from a WebSocket.OnMessage event. |
|
inlineprotected |
Sends a ping to the client for a session.
true
if the send has successfully done and a pong has been received within a time; otherwise, false
. InvalidOperationException | The Ping method is not available when the session has not started yet. |
|
inlineprotected |
Sends a ping with the specified message to the client for a 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. |
ArgumentException | message could not be UTF-8-encoded. |
ArgumentOutOfRangeException | The size of message is greater than 125 bytes. |
InvalidOperationException | The Ping method is not available when the session has not started yet. |
|
inlineprotected |
Sends the specified data to the client for a session.
data | An array of byte that specifies the binary data to send. |
ArgumentNullException | data is null . |
InvalidOperationException | The Send method is not available when the session has not started yet. -or- The Send method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the specified file to the client for a session.
fileInfo | A FileInfo that specifies the file to send. The file is sent as the binary data. |
ArgumentException | The file does not exist. -or- The file could not be opened. |
ArgumentNullException | fileInfo is null . |
InvalidOperationException | The Send method is not available when the session has not started yet. -or- The Send method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the data from the specified stream instance to the client for a 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. |
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 Send method is not available when the session has not started yet. -or- The Send method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the specified data to the client for a session.
data | A string that specifies the text data to send. |
ArgumentException | data could not be UTF-8-encoded. |
ArgumentNullException | data is null . |
InvalidOperationException | The Send method is not available when the session has not started yet. -or- The Send method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the specified data to the client for a 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. |
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. |
ArgumentNullException | data is null . |
InvalidOperationException | The SendAsync method is not available when the session has not started yet. -or- The SendAsync method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the specified file to the client for a session asynchronously.
This method does not wait for the send to be complete.
fileInfo | A FileInfo that specifies the file to send. The file is sent as the binary data. |
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 | The file does not exist. -or- The file could not be opened. |
ArgumentNullException | fileInfo is null . |
InvalidOperationException | The SendAsync method is not available when the session has not started yet. -or- The SendAsync method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the data from the specified stream instance to the client for a 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. |
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 | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
ArgumentNullException | stream is null . |
InvalidOperationException | The SendAsync method is not available when the session has not started yet. -or- The SendAsync method is not available when the current state of the WebSocket interface is not Open. |
|
inlineprotected |
Sends the specified data to the client for a session asynchronously.
This method does not wait for the send to be complete.
data | A string that specifies the text data to send. |
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 | data could not be UTF-8-encoded. |
ArgumentNullException | data is null . |
InvalidOperationException | The SendAsync method is not available when the session has not started yet. -or- The SendAsync method is not available when the current state of the WebSocket interface is not Open. |
|
getset |
Gets or sets the delegate used to respond to the HTTP cookies.
A T:System.Action<CookieCollection, CookieCollection> delegate.
It represents the delegate called when the WebSocket interface for a session respond to the handshake request.
1st CookieCollection parameter passed to the delegate contains the cookies included in the handshake request if any.
2nd CookieCollection parameter passed to the delegate holds the cookies to send to the client.
null
if not necessary.
The default value is null
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
getset |
Gets or sets a value indicating whether the WebSocket interface for a session emits the message event when it receives a ping.
true
if the interface emits the message event when it receives a ping; otherwise, false
.
The default value is false
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
getprotected |
Gets the HTTP headers for a session.
A NameValueCollection that contains the headers included in the WebSocket handshake request.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getset |
Gets or sets the delegate used to validate the Host header.
A T:System.Func<string, bool> delegate.
It represents the delegate called when the WebSocket interface for a session validates the handshake request.
The string parameter passed to the delegate is the value of the Host header.
The method invoked by the delegate must return true
if the header value is valid.
null
if not necessary.
The default value is null
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
get |
Gets the unique ID of a session.
A string that represents the unique ID of the session.
null
when the session has not started yet.
|
getset |
Gets or sets a value indicating whether the WebSocket interface for a session ignores the Sec-WebSocket-Extensions header.
true
if the interface ignores the extensions requested from the client; otherwise, false
.
The default value is false
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
getprotected |
Gets a value indicating whether the communication is possible for a session.
true
if the communication is possible; otherwise, false
.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getset |
Gets or sets a value indicating whether the underlying TCP socket of the WebSocket interface for a session disables a delay when send or receive buffer is not full.
true
if the delay is disabled; otherwise, false
.
The default value is false
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
getset |
Gets or sets the delegate used to validate the Origin header.
A T:System.Func<string, bool> delegate.
It represents the delegate called when the WebSocket interface for a session validates the handshake request.
The string parameter passed to the delegate is the value of the Origin header or null
if the header is not present.
The method invoked by the delegate must return true
if the header value is valid.
null
if not necessary.
The default value is null
.
InvalidOperationException | The set operation is not available when the session has already started. |
|
getset |
Gets or sets the name of the WebSocket subprotocol for a session.
A string that represents the name of the subprotocol.
The value specified for a set operation must be a token defined in RFC 2616
.
The value is initialized if not requested.
The default value is an empty string.
ArgumentException | The value specified for a set operation is not a token. |
InvalidOperationException | The set operation is not available when the session has already started. |
|
getprotected |
Gets the query string for a session.
A NameValueCollection that contains the query parameters included in the WebSocket handshake request.
An empty collection if not included.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getprotected |
Gets the current state of the WebSocket interface for a session.
One of the WebSocketState enum values.
It indicates the current state of the interface.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getprotected |
Gets the management function for the sessions in the service.
A WebSocketSessionManager that manages the sessions in the service.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
get |
Gets the time that a session has started.
A DateTime that represents the time that the session has started.
DateTime.MaxValue when the session has not started yet.
|
getprotected |
Gets the client information for a session.
A IPrincipal instance that represents identity, authentication, and security roles for the client.
null
if the client is not authenticated.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getprotected |
Gets the client endpoint for a session.
A System.Net.IPEndPoint that represents the client IP address and port number.
InvalidOperationException | The get operation is not available when the session has not started yet. |
|
getset |
Gets or sets the delegate used to respond to the user headers.
A T:System.Action<NameValueCollection, WebHeaderCollection> delegate.
It represents the delegate called when the WebSocket interface for a session respond to the handshake request.
1st NameValueCollection parameter passed to the delegate contains the HTTP headers included in the handshake request.
2nd WebHeaderCollection parameter passed to the delegate holds the user headers to send to the client.
null
if not necessary.
The default value is null
.
InvalidOperationException | The set operation is not available when the session has already started. |