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
파일 보기 프로젝트 열기: devicehive/devicehive-.net-mf 1 사용 예제들

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