cohtml.CohtmlWebSocketWrapper
Class wrapping around the .Net ClientWebSocket. Created when a CohtmlView component tries to establish a web socket connection.
Inherits from cohtml.Net.IClientSideSocket, SystemIDisposable
Public Functions
| Name | |
|---|---|
| CohtmlWebSocketWrapper(ISocketListener listener, string serverUrl, string [] protocols, int? timeoutMs, Action< WebSocketState > onWebsocketStateChangedCallback) Constructor for the WebSocket wrapper. | |
| override async void | Send(IntPtr messagePtr, uint length) Sends data over the WebSocket connection asynchronously. |
| virtual override void | Close(uint code, string reason, uint length) Closes the native side of the WebSocket connection. |
| virtual override void | Terminate(uint code, string reason, uint length) Initiates or completes the close handshake defined in the WebSocket protocol specification. |
| async void | RunWebSocketClientAsync() Connects to a WebSocket server as an asynchronous operation. |
| void | CloseCohtmlSocket(uint errorCode, string message) Closes the native side of the WebSocket connection. |
Public Properties
| Name | |
|---|---|
| ISocketListener | Listener Returns the ISocketListener of the native library. |
| Uri | ServerUrl Returns the server URL of the WebSocket. |
| string [] | Protocols Returns the protocols used by the WebSocket. |
Additional inherited members
Public Functions inherited from cohtml.Net.IClientSideSocket
| Name | |
|---|---|
| virtual void | Dispose() |
| IClientSideSocket() | |
| virtual uint | GetBufferedAmount() Called when the JS web socket want to get buffered amount of data. |
| virtual string | GetProtocol() Called when the JS web socket want to name of the sub-protocol the server selected. |
| delegate void | SwigDelegateIClientSideSocket_0(System.IntPtr bytes, uint length, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIClientSideSocket_1(System.IntPtr bytes, uint length, int opCode, global.System.IntPtr swigId) |
| delegate uint | SwigDelegateIClientSideSocket_2(global.System.IntPtr swigId) |
| delegate string | SwigDelegateIClientSideSocket_3(global.System.IntPtr swigId) |
| delegate void | SwigDelegateIClientSideSocket_4(uint code, string reason, uint length, global.System.IntPtr swigId) |
| delegate void | SwigDelegateIClientSideSocket_5(uint code, string reason, uint length, global.System.IntPtr swigId) |
Protected Attributes inherited from cohtml.Net.IClientSideSocket
| Name | |
|---|---|
| bool | swigCMemOwn |
Public Functions Documentation
function CohtmlWebSocketWrapper
CohtmlWebSocketWrapper(
ISocketListener listener,
string serverUrl,
string [] protocols,
int? timeoutMs,
Action< WebSocketState > onWebsocketStateChangedCallback
)
Constructor for the WebSocket wrapper.
Parameters:
- listener The native side of the connection which can be used to communicate with the CohtmlView component.
- serverUrl The URL to connect to; this should be the URL to which the WebSocket server will respond.
- protocols Either a single protocol string or an array of protocol strings. These strings are used to indicate sub-protocols, so that a single server can implement multiple WebSocket sub-protocols (for example, you might want one server to be able to handle different types of interactions depending on the specified protocol). If you don’t specify a protocol string, an empty string is assumed.
- timeoutMs Sets the WebSocket timeout.
- onWebsocketStateChangedCallback A callback that provides the current status of the WebSocket.
function Send
override async void Send(
IntPtr messagePtr,
uint length
)
Sends data over the WebSocket connection asynchronously.
function Close
virtual override void Close(
uint code,
string reason,
uint length
)
Closes the native side of the WebSocket connection.
Reimplements: cohtml.Net.IClientSideSocket.Close
function Terminate
virtual override void Terminate(
uint code,
string reason,
uint length
)
Initiates or completes the close handshake defined in the WebSocket protocol specification.
Reimplements: cohtml.Net.IClientSideSocket.Terminate
function RunWebSocketClientAsync
async void RunWebSocketClientAsync()
Connects to a WebSocket server as an asynchronous operation.
function CloseCohtmlSocket
void CloseCohtmlSocket(
uint errorCode,
string message
)
Closes the native side of the WebSocket connection.
Public Property Documentation
property Listener
ISocketListener Listener;
Returns the ISocketListener of the native library.
property ServerUrl
Uri ServerUrl;
Returns the server URL of the WebSocket.
property Protocols
string [] Protocols;
Returns the protocols used by the WebSocket.