C# Класс DeviceHive.Client.WebSocketChannel

Represents implementation of the persistent connection to the DeviceHive server using WebSocket API.
Наследование: Channel
Показать файл Открыть проект

Открытые методы

Метод Описание
CanConnectAsync ( ) : Task

Checks if current channel object can be used to eshtablish connection to the DeviceHive server. The method returns true only if the DeviceHive server deployment supports WebSocket protocol.

CloseAsync ( ) : Task

Closes the persistent connection to the DeviceHive server.

OpenAsync ( ) : Task

Opens a persistent connection to the DeviceHive server.

SendCommandAsync ( string deviceGuid, Command command, Action callback = null, CancellationToken token = null ) : Task

Sends a command to the device.

SendNotificationAsync ( string deviceGuid, Notification notification ) : Task

Sends a notification on behalf of device.

UpdateCommandAsync ( string deviceGuid, Command command ) : Task

Updates a command on behalf of the device.

WaitCommandResultAsync ( string deviceGuid, int commandId, CancellationToken token = null ) : Task

Waits until the command is completed and returns a Command object with filled Status and Result properties.

WebSocketChannel ( DeviceHive.Client.DeviceHiveConnectionInfo connectionInfo ) : Newtonsoft.Json.Linq

Default constructor.

WebSocketChannel ( DeviceHive.Client.DeviceHiveConnectionInfo connectionInfo, IRestClient restClient ) : Newtonsoft.Json.Linq

Constructor which allows to override IRestClient which makes HTTP requests to the DeviceHive server.

Защищенные методы

Метод Описание
SubscriptionAdding ( ISubscription subscription ) : Task

Invoked before new subscription is added. The methods sends subscribe message to the DeviceHive server.

SubscriptionRemoving ( ISubscription subscription ) : Task

Invoked before an existing subscription is removed. The methods sends unsubscribe message to the DeviceHive server.

Приватные методы

Метод Описание
AuthenticateAsync ( ) : Task
HandleConnectionClose ( ) : void
HandleMessage ( MessageWebSocketMessageReceivedEventArgs args ) : void
HandleMessage ( string message ) : void
OpenWebSocketAsync ( ) : Task
Reconnect ( ) : Task
SendRequestAsync ( string action ) : Task

Описание методов

CanConnectAsync() публичный Метод

Checks if current channel object can be used to eshtablish connection to the DeviceHive server. The method returns true only if the DeviceHive server deployment supports WebSocket protocol.
public CanConnectAsync ( ) : Task
Результат Task

CloseAsync() публичный Метод

Closes the persistent connection to the DeviceHive server.
public CloseAsync ( ) : Task
Результат Task

OpenAsync() публичный Метод

Opens a persistent connection to the DeviceHive server.
public OpenAsync ( ) : Task
Результат Task

SendCommandAsync() публичный Метод

Sends a command to the device.
public SendCommandAsync ( string deviceGuid, Command command, Action callback = null, CancellationToken token = null ) : Task
deviceGuid string Device unique identifier.
command Command A object to be sent.
callback Action A callback action to invoke when the command is completed by the device.
token System.Threading.CancellationToken Cancellation token to cancel waiting for command result.
Результат Task

SendNotificationAsync() публичный Метод

Sends a notification on behalf of device.
public SendNotificationAsync ( string deviceGuid, Notification notification ) : Task
deviceGuid string Device unique identifier.
notification Notification A object to be sent.
Результат Task

SubscriptionAdding() защищенный Метод

Invoked before new subscription is added. The methods sends subscribe message to the DeviceHive server.
protected SubscriptionAdding ( ISubscription subscription ) : Task
subscription ISubscription A object representing a subscription.
Результат Task

SubscriptionRemoving() защищенный Метод

Invoked before an existing subscription is removed. The methods sends unsubscribe message to the DeviceHive server.
protected SubscriptionRemoving ( ISubscription subscription ) : Task
subscription ISubscription A object representing a subscription.
Результат Task

UpdateCommandAsync() публичный Метод

Updates a command on behalf of the device.
public UpdateCommandAsync ( string deviceGuid, Command command ) : Task
deviceGuid string Device unique identifier.
command Command A object to update.
Результат Task

WaitCommandResultAsync() публичный Метод

Waits until the command is completed and returns a Command object with filled Status and Result properties.
public WaitCommandResultAsync ( string deviceGuid, int commandId, CancellationToken token = null ) : Task
deviceGuid string Device unique identifier.
commandId int Command identifier.
token System.Threading.CancellationToken Cancellation token to cancel waiting for command result.
Результат Task

WebSocketChannel() публичный Метод

Default constructor.
public WebSocketChannel ( DeviceHive.Client.DeviceHiveConnectionInfo connectionInfo ) : Newtonsoft.Json.Linq
connectionInfo DeviceHive.Client.DeviceHiveConnectionInfo DeviceHive connection information.
Результат Newtonsoft.Json.Linq

WebSocketChannel() публичный Метод

Constructor which allows to override IRestClient which makes HTTP requests to the DeviceHive server.
public WebSocketChannel ( DeviceHive.Client.DeviceHiveConnectionInfo connectionInfo, IRestClient restClient ) : Newtonsoft.Json.Linq
connectionInfo DeviceHive.Client.DeviceHiveConnectionInfo DeviceHive connection information.
restClient IRestClient IRestClient implementation.
Результат Newtonsoft.Json.Linq