My Project
|
Exposes a set of methods and properties used to define the behavior of a WebSocket service provided by the WebSocketServer or HttpServer class. More...
Protected Member Functions | |
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 code and reason. | |
void | Close (CloseStatusCode code, string reason) |
Closes the WebSocket connection for a session with the specified 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 code and reason. | |
void | CloseAsync (CloseStatusCode code, string reason) |
Closes the WebSocket connection for a session asynchronously with the specified 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. | |
Properties | |
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. | |
Func< CookieCollection, CookieCollection, bool > | CookiesValidator [get, set] |
Gets or sets the delegate used to validate the HTTP cookies. | |
bool | EmitOnPing [get, set] |
Gets or sets a value indicating whether the message event is emitted when the WebSocket interface for a session receives a ping. | |
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. | |
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. | |
![]() | |
string | ID [get] |
Gets the unique ID of the session. | |
DateTime | StartTime [get] |
Gets the time that the session has started. | |
WebSocket | WebSocket [get] |
Gets the WebSocket interface for the session. | |
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 |
Closes the WebSocket connection for a session.
This method does nothing if the current state of the WebSocket interface is Closing or Closed.
InvalidOperationException | The session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session with the specified code and reason.
This method does nothing if 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. |
InvalidOperationException | The session has not started yet. |
ArgumentException | 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. |
|
inlineprotected |
Closes the WebSocket connection for a session with the specified code and reason.
This method does nothing if 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. |
InvalidOperationException | The session has not started yet. |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
ArgumentException | code is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously.
This method does not wait for the close to be complete.
This method does nothing if the current state of the WebSocket interface is Closing or Closed.
InvalidOperationException | The session has not started yet. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously with the specified code and reason.
This method does not wait for the close to be complete.
This method does nothing if 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. |
InvalidOperationException | The session has not started yet. |
ArgumentException | 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. |
|
inlineprotected |
Closes the WebSocket connection for a session asynchronously with the specified code and reason.
This method does not wait for the close to be complete.
This method does nothing if 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. |
InvalidOperationException | The session has not started yet. |
ArgumentOutOfRangeException | code is less than 1000 or greater than 4999. -or- The size of reason is greater than 123 bytes. |
ArgumentException | code is 1010 (mandatory extension). -or- code is 1005 (no status) and reason is specified. -or- reason could not be UTF-8-encoded. |
|
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. |
Reimplemented in RconListener, and WebSocketListener.ListenerWebSocketBehavior.
|
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. |
Reimplemented in RconListener, and WebSocketListener.ListenerWebSocketBehavior.
|
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. |
Reimplemented in RconListener, and WebSocketListener.ListenerWebSocketBehavior.
|
inlineprotectedvirtual |
Called when the WebSocket connection for a session has been established.
Reimplemented in RconListener, and WebSocketListener.ListenerWebSocketBehavior.
|
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 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. |
InvalidOperationException | The session has not started yet. |
ArgumentException | message could not be UTF-8-encoded. |
ArgumentOutOfRangeException | The size of message is greater than 125 bytes. |
|
inlineprotected |
Sends the specified data to the client for a session.
data | An array of byte that specifies the binary data to send. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | data is null . |
|
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. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | fileInfo is null . |
ArgumentException | The file does not exist. -or- The file could not be opened. |
|
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. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | stream is null . |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
|
inlineprotected |
Sends the specified data to the client for a session.
data | A string that specifies the text data to send. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | data is null . |
ArgumentException | data could not be UTF-8-encoded. |
|
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. The delegate invokes the method called when the send is complete. The bool parameter passed to the method is true if the send has successfully done; otherwise, false . null if not necessary. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | data is null . |
|
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. The delegate invokes the method called when the send is complete. The bool parameter passed to the method is true if the send has successfully done; otherwise, false . null if not necessary. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | fileInfo is null . |
ArgumentException | The file does not exist. -or- The file could not be opened. |
|
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. The delegate invokes the method called when the send is complete. The bool parameter passed to the method is true if the send has successfully done; otherwise, false . null if not necessary. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | stream is null . |
ArgumentException | stream cannot be read. -or- length is less than 1. -or- No data could be read from stream . |
|
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. The delegate invokes the method called when the send is complete. The bool parameter passed to the method is true if the send has successfully done; otherwise, false . null if not necessary. |
InvalidOperationException | The session has not started yet. -or- The current state of the WebSocket interface is not Open. |
ArgumentNullException | data is null . |
ArgumentException | data could not be UTF-8-encoded. |
|
getset |
Gets or sets the delegate used to validate the HTTP cookies.
A T:System.Func<CookieCollection, CookieCollection, bool> delegate.
The delegate invokes the method called when the WebSocket interface for a session validates the handshake request.
1st CookieCollection parameter passed to the method contains the cookies to validate.
2nd CookieCollection parameter passed to the method receives the cookies to send to the client.
The method must return true
if the cookies are valid.
null
if not necessary.
The default value is null
.
|
getset |
Gets or sets a value indicating whether the message event is emitted when the WebSocket interface for a session receives a ping.
true
if the interface emits the message event when receives a ping; otherwise, false
.
The default value is false
.
|
getprotected |
Gets the HTTP headers for a session.
A NameValueCollection that contains the headers included in the WebSocket handshake request.
InvalidOperationException | The session has not started yet. |
|
get |
Gets the unique ID of a session.
A string that represents the unique ID of the session.
null
if the session has not started yet.
Implements WebSocketSharp.Server.IWebSocketSession.
|
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
.
|
getprotected |
Gets a value indicating whether the communication is possible for a session.
true
if the communication is possible; otherwise, false
.
InvalidOperationException | The session has not started yet. |
|
getset |
Gets or sets the delegate used to validate the Origin header.
A T:System.Func<string, bool> delegate.
The delegate invokes the method called when the WebSocket interface for a session validates the handshake request.
The string parameter passed to the method is the value of the Origin header or null
if the header is not present.
The method must return true
if the header value is valid.
null
if not necessary.
The default value is null
.
|
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 default value is an empty string.
InvalidOperationException | The set operation is not available if the session has already started. |
ArgumentException | The value specified for a set operation is not a token. |
|
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 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 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 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 if the session has not started yet.
Implements WebSocketSharp.Server.IWebSocketSession.
|
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 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 session has not started yet. |