Skip to content
SiteEmail

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

Name
CohtmlWebSocketWrapper(ISocketListener listener, string serverUrl, string [] protocols, int? timeoutMs, Action< WebSocketState > onWebsocketStateChangedCallback)
Constructor for the WebSocket wrapper.
override async voidSend(IntPtr messagePtr, uint length)
Sends data over the WebSocket connection asynchronously.
virtual override voidClose(uint code, string reason, uint length)
Closes the native side of the WebSocket connection.
virtual override voidTerminate(uint code, string reason, uint length)
Initiates or completes the close handshake defined in the WebSocket protocol specification.
async voidRunWebSocketClientAsync()
Connects to a WebSocket server as an asynchronous operation.
voidCloseCohtmlSocket(uint errorCode, string message)
Closes the native side of the WebSocket connection.
Name
ISocketListenerListener
Returns the ISocketListener of the native library.
UriServerUrl
Returns the server URL of the WebSocket.
string []Protocols
Returns the protocols used by the WebSocket.

Public Functions inherited from cohtml.Net.IClientSideSocket

Name
virtual voidDispose()
IClientSideSocket()
virtual uintGetBufferedAmount()
Called when the JS web socket want to get buffered amount of data.
virtual stringGetProtocol()
Called when the JS web socket want to name of the sub-protocol the server selected.
delegate voidSwigDelegateIClientSideSocket_0(System.IntPtr bytes, uint length, global.System.IntPtr swigId)
delegate voidSwigDelegateIClientSideSocket_1(System.IntPtr bytes, uint length, int opCode, global.System.IntPtr swigId)
delegate uintSwigDelegateIClientSideSocket_2(global.System.IntPtr swigId)
delegate stringSwigDelegateIClientSideSocket_3(global.System.IntPtr swigId)
delegate voidSwigDelegateIClientSideSocket_4(uint code, string reason, uint length, global.System.IntPtr swigId)
delegate voidSwigDelegateIClientSideSocket_5(uint code, string reason, uint length, global.System.IntPtr swigId)

Protected Attributes inherited from cohtml.Net.IClientSideSocket

Name
boolswigCMemOwn
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.
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.

Reimplements: cohtml.Net.IClientSideSocket.Close

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

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.

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.