|
EGDL2 2.1
|
Implements the WebSocket interface. More...
Inherits IDisposable.
Public Member Functions | |
| WebSocket (string url, params string[] protocols) | |
| Initializes a new instance of the WebSocket class with the specified WebSocket URL and subprotocols. | |
| void | Close () |
| Closes the WebSocket connection, and releases all associated resources. | |
| void | Close (ushort code) |
| Closes the WebSocket connection with the specified ushort, and releases all associated resources. | |
| void | Close (CloseStatusCode code) |
| Closes the WebSocket connection with the specified CloseStatusCode, and releases all associated resources. | |
| void | Close (ushort code, string reason) |
| Closes the WebSocket connection with the specified ushort and string, and releases all associated resources. | |
| void | Close (CloseStatusCode code, string reason) |
| Closes the WebSocket connection with the specified CloseStatusCode and string, and releases all associated resources. | |
| void | CloseAsync () |
| Closes the WebSocket connection asynchronously, and releases all associated resources. | |
| void | CloseAsync (ushort code) |
| Closes the WebSocket connection asynchronously with the specified ushort, and releases all associated resources. | |
| void | CloseAsync (CloseStatusCode code) |
| Closes the WebSocket connection asynchronously with the specified CloseStatusCode, and releases all associated resources. | |
| void | CloseAsync (ushort code, string reason) |
| Closes the WebSocket connection asynchronously with the specified ushort and string, and releases all associated resources. | |
| void | CloseAsync (CloseStatusCode code, string reason) |
| Closes the WebSocket connection asynchronously with the specified CloseStatusCode and string, and releases all associated resources. | |
| void | Connect () |
| Establishes a WebSocket connection. | |
| void | ConnectAsync () |
| Establishes a WebSocket connection asynchronously. | |
| bool | Ping () |
| Sends a Ping using the WebSocket connection. | |
| bool | Ping (string message) |
| Sends a Ping with the specified message using the WebSocket connection. | |
| void | Send (byte[] data) |
| Sends a binary data using the WebSocket connection. | |
| void | Send (FileInfo file) |
| Sends the specified file as a binary data using the WebSocket connection. | |
| void | Send (string data) |
| Sends a text data using the WebSocket connection. | |
| void | SendAsync (byte[] data, Action< bool > completed) |
| Sends a binary data asynchronously using the WebSocket connection. | |
| void | SendAsync (FileInfo file, Action< bool > completed) |
| Sends the specified file as a binary data asynchronously using the WebSocket connection. | |
| void | SendAsync (string data, Action< bool > completed) |
| Sends a text data asynchronously using the WebSocket connection. | |
| void | SendAsync (Stream stream, int length, Action< bool > completed) |
| Sends a binary data from the specified Stream asynchronously using the WebSocket connection. | |
| void | SetCookie (Cookie cookie) |
| Sets an HTTP cookie to send with the WebSocket connection request to the server. | |
| void | SetCredentials (string username, string password, bool preAuth) |
| Sets a pair of username and password for the HTTP authentication (Basic/Digest). | |
Properties | |
| CompressionMethod | Compression [get, set] |
| Gets or sets the compression method used to compress the message on the WebSocket connection. | |
| IEnumerable< Cookie > | Cookies [get] |
| Gets the HTTP cookies included in the WebSocket connection request and response. | |
| NetworkCredential | Credentials [get] |
| Gets the credentials for the HTTP authentication (Basic/Digest). | |
| string | Extensions [get] |
| Gets the WebSocket extensions selected by the server. | |
| bool | IsAlive [get] |
| Gets a value indicating whether the WebSocket connection is alive. | |
| bool | IsSecure [get] |
| Gets a value indicating whether the WebSocket connection is secure. | |
| Logger | Log [get, set] |
| Gets the logging functions. | |
| string | Origin [get, set] |
| Gets or sets the value of the Origin header to send with the WebSocket connection request to the server. | |
| string | Protocol [get, set] |
| Gets the WebSocket subprotocol selected by the server. | |
| WebSocketState | ReadyState [get] |
| Gets the state of the WebSocket connection. | |
| RemoteCertificateValidationCallback | ServerCertificateValidationCallback [get, set] |
| Gets or sets the callback used to validate the certificate supplied by the server. | |
| Uri | Url [get] |
| Gets the WebSocket URL to connect. | |
Events | |
| EventHandler< CloseEventArgs > | OnClose |
| Occurs when the WebSocket connection has been closed. | |
| EventHandler< ErrorEventArgs > | OnError |
| Occurs when the WebSocket gets an error. | |
| EventHandler< MessageEventArgs > | OnMessage |
| Occurs when the WebSocket receives a message. | |
| EventHandler | OnOpen |
| Occurs when the WebSocket connection has been established. | |
Implements the WebSocket interface.
The WebSocket class provides a set of methods and properties for two-way communication using the WebSocket protocol (RFC 6455
).
|
inline |
Initializes a new instance of the WebSocket class with the specified WebSocket URL and subprotocols.
| url | A string that represents the WebSocket URL to connect. |
| protocols | An array of string that contains the WebSocket subprotocols if any. Each value of protocols must be a token defined in RFC 2616. |
| ArgumentException | url is invalid. -or- protocols is invalid. |
| ArgumentNullException | url is null. |
|
inline |
Closes the WebSocket connection with the specified CloseStatusCode, and releases all associated resources.
| code | One of the CloseStatusCode enum values, represents the status code indicating the reason for closure. |
|
inline |
Closes the WebSocket connection with the specified CloseStatusCode and string, and releases all associated resources.
This method emits a OnError event if the size of reason is greater than 123 bytes.
| code | One of the CloseStatusCode enum values, represents the status code indicating the reason for closure. |
| reason | A string that represents the reason for closure. |
|
inline |
Closes the WebSocket connection with the specified ushort, and releases all associated resources.
This method emits a OnError event if code isn't in the allowable range of the WebSocket close status code.
| code | A ushort that represents the status code indicating the reason for closure. |
|
inline |
Closes the WebSocket connection with the specified ushort and string, and releases all associated resources.
This method emits a OnError event if code isn't in the allowable range of the WebSocket close status code or the size of reason is greater than 123 bytes.
| code | A ushort that represents the status code indicating the reason for closure. |
| reason | A string that represents the reason for closure. |
|
inline |
Closes the WebSocket connection asynchronously, and releases all associated resources.
This method doesn't wait for the close to be complete.
|
inline |
Closes the WebSocket connection asynchronously with the specified CloseStatusCode, and releases all associated resources.
This method doesn't wait for the close to be complete.
| code | One of the CloseStatusCode enum values, represents the status code indicating the reason for closure. |
|
inline |
Closes the WebSocket connection asynchronously with the specified CloseStatusCode and string, and releases all associated resources.
This method doesn't wait for the close to be complete.
This method emits a OnError event if the size of reason is greater than 123 bytes.
| code | One of the CloseStatusCode enum values, represents the status code indicating the reason for closure. |
| reason | A string that represents the reason for closure. |
|
inline |
Closes the WebSocket connection asynchronously with the specified ushort, and releases all associated resources.
This method doesn't wait for the close to be complete.
This method emits a OnError event if code isn't in the allowable range of the WebSocket close status code.
| code | A ushort that represents the status code indicating the reason for closure. |
|
inline |
Closes the WebSocket connection asynchronously with the specified ushort and string, and releases all associated resources.
This method doesn't wait for the close to be complete.
This method emits a OnError event if code isn't in the allowable range of the WebSocket close status code or the size of reason is greater than 123 bytes.
| code | A ushort that represents the status code indicating the reason for closure. |
| reason | A string that represents the reason for closure. |
|
inline |
Establishes a WebSocket connection asynchronously.
This method doesn't wait for the connect to be complete.
|
inline |
Sends a Ping using the WebSocket connection.
true if the WebSocket receives a Pong to this Ping in a time; otherwise, false.
|
inline |
Sends a Ping with the specified message using the WebSocket connection.
true if the WebSocket receives a Pong to this Ping in a time; otherwise, false. | message | A string that represents the message to send. |
|
inline |
Sends a binary data using the WebSocket connection.
| data | An array of byte that represents the binary data to send. |
|
inline |
Sends the specified file as a binary data using the WebSocket connection.
| file | A FileInfo that represents the file to send. |
|
inline |
Sends a text data using the WebSocket connection.
| data | A string that represents the text data to send. |
|
inline |
Sends a binary data asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
| data | An array of byte that represents the binary data to send. |
| completed | An Action<bool> delegate that references the method(s) called when the send is complete. A bool passed to this delegate is true if the send is complete successfully; otherwise, false. |
|
inline |
Sends the specified file as a binary data asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
| file | A FileInfo that represents the file to send. |
| completed | An Action<bool> delegate that references the method(s) called when the send is complete. A bool passed to this delegate is true if the send is complete successfully; otherwise, false. |
|
inline |
Sends a binary data from the specified Stream asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
| stream | A Stream from which contains the binary data to send. |
| length | An int that represents the number of bytes to send. |
| completed | An Action<bool> delegate that references the method(s) called when the send is complete. A bool passed to this delegate is true if the send is complete successfully; otherwise, false. |
|
inline |
Sends a text data asynchronously using the WebSocket connection.
This method doesn't wait for the send to be complete.
| data | A string that represents the text data to send. |
| completed | An Action<bool> delegate that references the method(s) called when the send is complete. A bool passed to this delegate is true if the send is complete successfully; otherwise, false. |
|
inline |
Sets an HTTP cookie to send with the WebSocket connection request to the server.
| cookie | A Cookie that represents the cookie to send. |
|
inline |
Sets a pair of username and password for the HTTP authentication (Basic/Digest).
| username | A string that represents the user name used to authenticate. |
| password | A string that represents the password for username used to authenticate. |
| preAuth | true if the WebSocket sends the Basic authentication credentials with the first connection request to the server; otherwise, false. |
|
getset |
Gets or sets the compression method used to compress the message on the WebSocket connection.
One of the CompressionMethod enum values, indicates the compression method used to compress the message. The default value is CompressionMethod.None.
|
get |
Gets the HTTP cookies included in the WebSocket connection request and response.
An IEnumerable<Cookie> instance that provides an enumerator which supports the iteration over the collection of the cookies.
|
get |
Gets the credentials for the HTTP authentication (Basic/Digest).
A NetworkCredential that represents the credentials for the HTTP authentication. The default value is null.
|
get |
Gets the WebSocket extensions selected by the server.
A string that represents the extensions if any. The default value is String.Empty.
|
get |
Gets a value indicating whether the WebSocket connection is alive.
true if the connection is alive; otherwise, false.
|
get |
Gets a value indicating whether the WebSocket connection is secure.
true if the connection is secure; otherwise, false.
|
getset |
Gets the logging functions.
The default logging level is LogLevel.Error. If you would like to change it, you should set the Log.Level property to any of the LogLevel enum values.
A Logger that provides the logging functions.
|
getset |
Gets or sets the value of the Origin header to send with the WebSocket connection request to the server.
The WebSocket sends the Origin header if this property has any.
A string that represents the value of the HTTP Origin header
to send. The default value is null.
The Origin header has the following syntax: <scheme>://<host>[:<port>]
|
getset |
Gets the WebSocket subprotocol selected by the server.
A string that represents the subprotocol if any. The default value is String.Empty.
|
get |
Gets the state of the WebSocket connection.
One of the WebSocketState enum values, indicates the state of the WebSocket connection. The default value is WebSocketState.Connecting.
|
getset |
Gets or sets the callback used to validate the certificate supplied by the server.
If the value of this property is null, the validation does nothing with the server certificate, always returns valid.
A RemoteCertificateValidationCallback delegate that references the method(s) used to validate the server certificate. The default value is null.
|
get |
Gets the WebSocket URL to connect.
A Uri that represents the WebSocket URL to connect.