C# Класс DeviceHive.HttpClient

HTTP client for restful HTTP service
Complies to HTTP protocol v.6. Implements device-specific commands for .NET Micro Framework device.
Наследование: IFrameworkClient
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
GetResponseAsync System.Net.HttpWebResponse
MakeRequest System.Net.WebResponse

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

Метод Описание
GetApiInfo ( ) : ApiInfo

Gets API info.

GetCommand ( Device device, bool onlyUnprocessed = true ) : DeviceCommand

Gets a command

This method returns all the commands that are waiting at the server since last GetCommand call. It returns immediately, regardless if there are commands to execute or not.

HttpClient ( string Url, int RequestTimeout, string TimeStamp = null ) : System

Constructs an HTTP client object

If the caller has no intention to set a specific time stamp, DeteTime.MinValue can be used.

PollCommand ( Device device, bool onlyUnprocessed = true ) : DeviceCommand

Polls command for execution

This method returns the next command from the command queue. If there are no commands in the queue, it waits for ~30 seconds to receive a new command.

PostNotification ( Device device, INotification notification ) : bool

Sends a notification

This method can be used by devices to send notifications.

SetDevice ( Device device ) : bool

Registers a device

This method is called by device to register it at the server.

UpdateCommandStatus ( Device device, string CommandId, CommandStatus status ) : bool

Updates command status

The devices are using this method to notify the server of command completion and its result.

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

Метод Описание
GetResponseAsync ( HttpWebRequest req ) : HttpWebResponse

Performs an asynchronous request and returns its response

MakeRequest ( string url, object obj, string Method, string id, string key ) : WebResponse

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

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

Gets API info.
public GetApiInfo ( ) : ApiInfo
Результат ApiInfo

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

Gets a command
This method returns all the commands that are waiting at the server since last GetCommand call. It returns immediately, regardless if there are commands to execute or not.
public GetCommand ( Device device, bool onlyUnprocessed = true ) : DeviceCommand
device Device Device data of the device that is getting a command
onlyUnprocessed bool Get commands with empty status only
Результат DeviceCommand

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

Constructs an HTTP client object
If the caller has no intention to set a specific time stamp, DeteTime.MinValue can be used.
public HttpClient ( string Url, int RequestTimeout, string TimeStamp = null ) : System
Url string URL of the DeviceHive server
RequestTimeout int Maximum request timeout
TimeStamp string Timastamp of the last command
Результат System

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

Polls command for execution
This method returns the next command from the command queue. If there are no commands in the queue, it waits for ~30 seconds to receive a new command.
public PollCommand ( Device device, bool onlyUnprocessed = true ) : DeviceCommand
device Device Device data of the device that is polling a command
onlyUnprocessed bool Get commands with empty status only
Результат DeviceCommand

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

Sends a notification
This method can be used by devices to send notifications.
public PostNotification ( Device device, INotification notification ) : bool
device Device Device data of the device that is sending the notification
notification INotification Notification to be sent
Результат bool

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

Registers a device
This method is called by device to register it at the server.
public SetDevice ( Device device ) : bool
device Device Device data structure
Результат bool

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

Updates command status
The devices are using this method to notify the server of command completion and its result.
public UpdateCommandStatus ( Device device, string CommandId, CommandStatus status ) : bool
device Device Device data of the device that is updating a command status
CommandId string ID of the command to be updated
status CommandStatus Status of the command
Результат bool