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

Exposes a set of methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or HttpServer class. [詳解]

WebSocketSharp.Server.WebSocketBehavior の継承関係図
WebSocketSharp.Server.IWebSocketSession

限定公開メンバ関数

 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, CookieCollectionCookiesResponder [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, WebHeaderCollectionUserHeadersResponder [get, set]
 Gets or sets the delegate used to respond to the user headers.
 
- 基底クラス WebSocketSharp.Server.IWebSocketSession に属する継承プロパティ

詳解

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.

関数詳解

◆ Close() [1/3]

void WebSocketSharp.Server.WebSocketBehavior.Close ( )
inlineprotected

Closes the WebSocket connection for a session.

This method does nothing when the current state of the WebSocket interface is Closing or Closed.

例外
InvalidOperationExceptionThe Close method is not available when the session has not started yet.

◆ Close() [2/3]

void WebSocketSharp.Server.WebSocketBehavior.Close ( CloseStatusCode code,
string reason )
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.

引数
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.
例外
ArgumentExceptioncode 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.
ArgumentOutOfRangeExceptionThe size of reason is greater than 123 bytes.
InvalidOperationExceptionThe Close method is not available when the session has not started yet.

◆ Close() [3/3]

void WebSocketSharp.Server.WebSocketBehavior.Close ( ushort code,
string reason )
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.

引数
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.
例外
ArgumentExceptioncode is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded.
ArgumentOutOfRangeExceptioncode is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes.
InvalidOperationExceptionThe Close method is not available when the session has not started yet.

◆ CloseAsync() [1/3]

void WebSocketSharp.Server.WebSocketBehavior.CloseAsync ( )
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.

例外
InvalidOperationExceptionThe CloseAsync method is not available when the session has not started yet.

◆ CloseAsync() [2/3]

void WebSocketSharp.Server.WebSocketBehavior.CloseAsync ( CloseStatusCode code,
string reason )
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.

引数
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.
例外
ArgumentExceptioncode 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.
ArgumentOutOfRangeExceptionThe size of reason is greater than 123 bytes.
InvalidOperationExceptionThe CloseAsync method is not available when the session has not started yet.

◆ CloseAsync() [3/3]

void WebSocketSharp.Server.WebSocketBehavior.CloseAsync ( ushort code,
string reason )
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.

引数
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.
例外
ArgumentExceptioncode is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded.
ArgumentOutOfRangeExceptioncode is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes.
InvalidOperationExceptionThe CloseAsync method is not available when the session has not started yet.

◆ OnClose()

virtual void WebSocketSharp.Server.WebSocketBehavior.OnClose ( CloseEventArgs e)
inlineprotectedvirtual

Called when the WebSocket connection for a session has been closed.

引数
eA CloseEventArgs that represents the event data passed from a WebSocket.OnClose event.

◆ OnError()

virtual void WebSocketSharp.Server.WebSocketBehavior.OnError ( ErrorEventArgs e)
inlineprotectedvirtual

Called when the WebSocket interface for a session gets an error.

引数
eA ErrorEventArgs that represents the event data passed from a WebSocket.OnError event.

◆ OnMessage()

virtual void WebSocketSharp.Server.WebSocketBehavior.OnMessage ( MessageEventArgs e)
inlineprotectedvirtual

Called when the WebSocket interface for a session receives a message.

引数
eA MessageEventArgs that represents the event data passed from a WebSocket.OnMessage event.

◆ Ping() [1/2]

bool WebSocketSharp.Server.WebSocketBehavior.Ping ( )
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.
例外
InvalidOperationExceptionThe Ping method is not available when the session has not started yet.

◆ Ping() [2/2]

bool WebSocketSharp.Server.WebSocketBehavior.Ping ( string message)
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.
引数
messageA string that specifies the message to send. Its size must be 125 bytes or less in UTF-8.
例外
ArgumentExceptionmessage could not be UTF-8-encoded.
ArgumentOutOfRangeExceptionThe size of message is greater than 125 bytes.
InvalidOperationExceptionThe Ping method is not available when the session has not started yet.

◆ Send() [1/4]

void WebSocketSharp.Server.WebSocketBehavior.Send ( byte[] data)
inlineprotected

Sends the specified data to the client for a session.

引数
dataAn array of byte that specifies the binary data to send.
例外
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe 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.

◆ Send() [2/4]

void WebSocketSharp.Server.WebSocketBehavior.Send ( FileInfo fileInfo)
inlineprotected

Sends the specified file to the client for a session.

引数
fileInfoA FileInfo that specifies the file to send. The file is sent as the binary data.
例外
ArgumentExceptionThe file does not exist. -or- The file could not be opened.
ArgumentNullExceptionfileInfo is null.
InvalidOperationExceptionThe 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.

◆ Send() [3/4]

void WebSocketSharp.Server.WebSocketBehavior.Send ( Stream stream,
int length )
inlineprotected

Sends the data from the specified stream instance to the client for a 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.
例外
ArgumentExceptionstream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionstream is null.
InvalidOperationExceptionThe 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.

◆ Send() [4/4]

void WebSocketSharp.Server.WebSocketBehavior.Send ( string data)
inlineprotected

Sends the specified data to the client for a session.

引数
dataA string that specifies the text data to send.
例外
ArgumentExceptiondata could not be UTF-8-encoded.
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe 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.

◆ SendAsync() [1/4]

void WebSocketSharp.Server.WebSocketBehavior.SendAsync ( byte[] data,
Action< bool > completed )
inlineprotected

Sends the specified data to the client for a session asynchronously.

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

引数
dataAn array of byte that specifies the binary data to send.
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.
例外
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe 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.

◆ SendAsync() [2/4]

void WebSocketSharp.Server.WebSocketBehavior.SendAsync ( FileInfo fileInfo,
Action< bool > completed )
inlineprotected

Sends the specified file to the client for a session asynchronously.

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

引数
fileInfoA FileInfo that specifies the file to send. The file is sent as the binary data.
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.
例外
ArgumentExceptionThe file does not exist. -or- The file could not be opened.
ArgumentNullExceptionfileInfo is null.
InvalidOperationExceptionThe 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.

◆ SendAsync() [3/4]

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

引数
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 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.
例外
ArgumentExceptionstream cannot be read. -or- length is less than 1. -or- No data could be read from stream .
ArgumentNullExceptionstream is null.
InvalidOperationExceptionThe 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.

◆ SendAsync() [4/4]

void WebSocketSharp.Server.WebSocketBehavior.SendAsync ( string data,
Action< bool > completed )
inlineprotected

Sends the specified data to the client for a session asynchronously.

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

引数
dataA string that specifies the text data to send.
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.
例外
ArgumentExceptiondata could not be UTF-8-encoded.
ArgumentNullExceptiondata is null.
InvalidOperationExceptionThe 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.

プロパティ詳解

◆ CookiesResponder

Action<CookieCollection, CookieCollection> WebSocketSharp.Server.WebSocketBehavior.CookiesResponder
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ EmitOnPing

bool WebSocketSharp.Server.WebSocketBehavior.EmitOnPing
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ Headers

NameValueCollection WebSocketSharp.Server.WebSocketBehavior.Headers
getprotected

Gets the HTTP headers for a session.

A NameValueCollection that contains the headers included in the WebSocket handshake request.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ HostValidator

Func<string, bool> WebSocketSharp.Server.WebSocketBehavior.HostValidator
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ ID

string WebSocketSharp.Server.WebSocketBehavior.ID
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.

WebSocketSharp.Server.IWebSocketSessionを実装しています。

◆ IgnoreExtensions

bool WebSocketSharp.Server.WebSocketBehavior.IgnoreExtensions
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ IsAlive

bool WebSocketSharp.Server.WebSocketBehavior.IsAlive
getprotected

Gets a value indicating whether the communication is possible for a session.

true if the communication is possible; otherwise, false.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ NoDelay

bool WebSocketSharp.Server.WebSocketBehavior.NoDelay
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.

参照
System.Net.Sockets.Socket.NoDelay
例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ OriginValidator

Func<string, bool> WebSocketSharp.Server.WebSocketBehavior.OriginValidator
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ Protocol

string WebSocketSharp.Server.WebSocketBehavior.Protocol
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.

例外
ArgumentExceptionThe value specified for a set operation is not a token.
InvalidOperationExceptionThe set operation is not available when the session has already started.

◆ QueryString

NameValueCollection WebSocketSharp.Server.WebSocketBehavior.QueryString
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.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ ReadyState

WebSocketState WebSocketSharp.Server.WebSocketBehavior.ReadyState
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.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ Sessions

WebSocketSessionManager WebSocketSharp.Server.WebSocketBehavior.Sessions
getprotected

Gets the management function for the sessions in the service.

A WebSocketSessionManager that manages the sessions in the service.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ StartTime

DateTime WebSocketSharp.Server.WebSocketBehavior.StartTime
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.

WebSocketSharp.Server.IWebSocketSessionを実装しています。

◆ User

IPrincipal WebSocketSharp.Server.WebSocketBehavior.User
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.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ UserEndPoint

System.Net.IPEndPoint WebSocketSharp.Server.WebSocketBehavior.UserEndPoint
getprotected

Gets the client endpoint for a session.

A System.Net.IPEndPoint that represents the client IP address and port number.

例外
InvalidOperationExceptionThe get operation is not available when the session has not started yet.

◆ UserHeadersResponder

Action<NameValueCollection, WebHeaderCollection> WebSocketSharp.Server.WebSocketBehavior.UserHeadersResponder
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.

例外
InvalidOperationExceptionThe set operation is not available when the session has already started.

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