Interface IWebSocketClient
An interface for using a Messaging client and listen to events.
Inherited Members
Namespace: Unity.Cloud.Common
Syntax
public interface IWebSocketClient : IDisposable
Properties
State
Reference to the current state of the connection
Declaration
ConnectionState State { get; }
Property Value
Type | Description |
---|---|
ConnectionState |
Methods
ConnectAsync(Uri, HttpHeaders)
Attempts opening a connection to a server
Declaration
Task ConnectAsync(Uri uri, HttpHeaders headers = null)
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | The uri to connect to. |
HttpHeaders | headers | The HTTP headers for the connection request. |
Returns
Type | Description |
---|---|
Task | The connection task. |
DisconnectAsync()
Closes a connection to a server
Declaration
Task DisconnectAsync()
Returns
Type | Description |
---|---|
Task | The disconnection task. |
SendAsync(ArraySegment<Byte>)
Method to send binary data to a server
Declaration
Task SendAsync(ArraySegment<byte> message)
Parameters
Type | Name | Description |
---|---|---|
ArraySegment<Byte> | message | The message to send. |
Returns
Type | Description |
---|---|
Task | The send message task. |
SendAsync(String)
Sends a message to a server.
Declaration
Task SendAsync(string message)
Parameters
Type | Name | Description |
---|---|---|
String | message | The message to send. |
Returns
Type | Description |
---|---|
Task | The send message task. |
Events
ConnectionErrorOccured
Event invoked when a connection error occurs
Declaration
event Action<Exception> ConnectionErrorOccured
Event Type
Type | Description |
---|---|
Action<Exception> |
ConnectionStateChanged
Event invoked when the state changes
Declaration
event Action<ConnectionState> ConnectionStateChanged
Event Type
Type | Description |
---|---|
Action<ConnectionState> |
DataReceived
Event invoked when binary data is received from the server
Declaration
event Action<ArraySegment<byte>> DataReceived
Event Type
Type | Description |
---|---|
Action<ArraySegment<Byte>> |
MessageReceived
Event invoked when a message is received from the server
Declaration
event Action<string> MessageReceived
Event Type
Type | Description |
---|---|
Action<String> |