Class ServiceMessagingClient
Interface for a messaging client used to connect to a service and send/receive messages
Inherited Members
Namespace: Unity.Cloud.Common
Syntax
public class ServiceMessagingClient : IServiceMessagingClient, IDisposable
Constructors
ServiceMessagingClient(IWebSocketClient, IAccessTokenProvider, IAppIdProvider)
Creates an instance of ServiceMessagingClient
Declaration
public ServiceMessagingClient(IWebSocketClient webSocketClient, IAccessTokenProvider accessTokenProvider = null, IAppIdProvider appIdProvider = null)
Parameters
Type | Name | Description |
---|---|---|
IWebSocketClient | webSocketClient | IWebSocketClient provided. |
IAccessTokenProvider | accessTokenProvider | Provider of access tokens. |
IAppIdProvider | appIdProvider | Provider of the application identifier. |
Properties
State
Reference to the current state of the connection
Declaration
public ConnectionState State { get; }
Property Value
Type | Description |
---|---|
ConnectionState |
Implements
Methods
AddApiSourceVersion(String, String)
Adds an ApiSourceVersion to the client.
Declaration
public void AddApiSourceVersion(string name, string version)
Parameters
Type | Name | Description |
---|---|---|
String | name | The API source name. |
String | version | The API source version. |
Implements
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown is |
AddApiSourceVersion(ApiSourceVersion)
Adds an ApiSourceVersion to the client.
Declaration
public void AddApiSourceVersion(ApiSourceVersion apiSourceVersion)
Parameters
Type | Name | Description |
---|---|---|
ApiSourceVersion | apiSourceVersion | The version information for the API using this client. |
Implements
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ConnectAsync(Uri, ServiceMessagingClientOptions, CancellationToken)
Awaitable method to open a connection to a service using the given url using messaging client options
Declaration
public async Task ConnectAsync(Uri uri, ServiceMessagingClientOptions options = default(ServiceMessagingClientOptions), CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Uri | uri | Uri |
ServiceMessagingClientOptions | options | The selected options |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task |
Implements
DisconnectAsync()
Awaitable method to close a connection to a server
Declaration
public Task DisconnectAsync()
Returns
Type | Description |
---|---|
Task |
Implements
Dispose()
Ensure disposal of any IDisposable references.
Declaration
public void Dispose()
Implements
Dispose(Boolean)
Ensure internal disposal of any IDisposable references.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
Boolean | disposing | Dispose pattern boolean value received from public Dispose method. |
SendAsync(IEnumerable<Message>)
Awaitable method to send a collection of messages to a server
Declaration
public Task SendAsync(IEnumerable<Message> messages)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Message> | messages |
Returns
Type | Description |
---|---|
Task |
Implements
SendAsync(Message)
Awaitable method to send a message to a server
Declaration
public Task SendAsync(Message message)
Parameters
Type | Name | Description |
---|---|---|
Message | message |
Returns
Type | Description |
---|---|
Task |
Implements
Events
ConnectionErrorOccured
Event invoked when a connection error occurs
Declaration
public event Action<Exception> ConnectionErrorOccured
Event Type
Type | Description |
---|---|
Action<Exception> |
Implements
ConnectionStateChanged
Event invoked when the client's connection state changes
Declaration
public event Action<ConnectionState> ConnectionStateChanged
Event Type
Type | Description |
---|---|
Action<ConnectionState> |
Implements
MessageReceived
Event invoked when a message is received from the server
Declaration
public event Action<Message> MessageReceived
Event Type
Type | Description |
---|---|
Action<Message> |