Class ServiceMessagingClient
Interface for a messaging client used to connect to a service and send/receive messages
Inherited Members
Namespace: Unity.Cloud.Common
Assembly: Unity.Cloud.Common.dll
Syntax
public class ServiceMessagingClient : IServiceMessagingClient, IDisposable
  Constructors
ServiceMessagingClient(IWebSocketClient, IServiceAuthorizer, IAppIdProvider)
Creates an instance of ServiceMessagingClient
Declaration
public ServiceMessagingClient(IWebSocketClient webSocketClient, IServiceAuthorizer serviceAuthorizer = null, IAppIdProvider appIdProvider = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IWebSocketClient | webSocketClient | IWebSocketClient provided.  | 
      
| IServiceAuthorizer | serviceAuthorizer | Authorizer to add authorization information to requests.  | 
      
| 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 | 
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.  | 
      
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.  | 
      
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 Task ConnectAsync(Uri uri, ServiceMessagingClientOptions options = default, CancellationToken cancellationToken = default)
  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 | A Task for the connection operation.  | 
      
DisconnectAsync()
Awaitable method to close a connection to a server
Declaration
public Task DisconnectAsync()
  Returns
| Type | Description | 
|---|---|
| Task | A Task for the disconnection operation.  | 
      
Dispose()
Ensure disposal of any IDisposable references.
Declaration
public void Dispose()
  Dispose(bool)
Ensure internal disposal of any IDisposable references.
Declaration
protected virtual void Dispose(bool disposing)
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | 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 | A Task for the send operation.  | 
      
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 | A Task for the send operation.  | 
      
Events
ConnectionErrorOccured
Event invoked when a connection error occurs
Declaration
public event Action<Exception> ConnectionErrorOccured
  Event Type
| Type | Description | 
|---|---|
| Action<Exception> | 
ConnectionStateChanged
Event invoked when the client's connection state changes
Declaration
public event Action<ConnectionState> ConnectionStateChanged
  Event Type
| Type | Description | 
|---|---|
| Action<ConnectionState> | 
MessageReceived
Event invoked when a message is received from the server
Declaration
public event Action<Message> MessageReceived
  Event Type
| Type | Description | 
|---|---|
| Action<Message> |