Interface IWebSocket
Assembly: Glitch9.IO.dll
Syntax
public interface IWebSocket : IDisposable
Properties
|
Edit this page
View Source
OnStateChanged
Event handler for when the WebSocket connection state changes.
Declaration
Action<WebSocketState> OnStateChanged { get; set; }
Property Value
|
Edit this page
View Source
State
The current state of the WebSocket connection.
Declaration
WebSocketState State { get; }
Property Value
|
Edit this page
View Source
SubProtocol
The WebSocket connection object.
Declaration
string SubProtocol { get; }
Property Value
Methods
|
Edit this page
View Source
CloseAsync(WebSocketCloseStatus, string, CancellationToken)
Close the WebSocket connection.
Declaration
UniTask CloseAsync(WebSocketCloseStatus closeStatus, string closeDescription, CancellationToken cancellationToken)
Parameters
| Type |
Name |
Description |
| WebSocketCloseStatus |
closeStatus |
The status code indicating the reason for closing the connection.
|
| string |
closeDescription |
The reason for closing the connection.
|
| CancellationToken |
cancellationToken |
|
Returns
|
Edit this page
View Source
Connect to the WebSocket server with a Uri endpoint URL.
Declaration
UniTask ConnectAsync(Uri uri, CancellationToken cancellationToken, params HttpHeader[] headers)
Parameters
Returns
|
Edit this page
View Source
ReceiveAsync(ArraySegment<byte>, CancellationToken)
Receive a response from the WebSocket server.
Declaration
UniTask<WebSocketReceiveResult> ReceiveAsync(ArraySegment<byte> buffer, CancellationToken cancellationToken)
Parameters
Returns
|
Edit this page
View Source
SendAsync(ArraySegment<byte>, WebSocketMessageType, bool, CancellationToken)
Send a buffer to the WebSocket server.
The buffer is binary data.
This is WebSocket equivalent of multi-part/form-data.
Declaration
UniTask SendAsync(ArraySegment<byte> buffer, WebSocketMessageType messageType, bool endOfMessage, CancellationToken token)
Parameters
Returns
|
Edit this page
View Source
SendAsync(string, CancellationToken)
Send a message to the WebSocket server.
The message is most likely a JSON string.
This is WebSocket equivalent of application/json.
Declaration
UniTask SendAsync(string jsonString, CancellationToken token)
Parameters
Returns
Extension Methods