C# Класс HarmonyHub.HarmonyClient

Client to interrogate and control Logitech Harmony Hub.
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
Create ( string host, string token, int port = 5222 ) : HarmonyClient

Create a HarmonyClient with pre-authenticated token

Create ( string host, string username, string password, int port = 5222 ) : Task

Create a harmony client via myharmony.com authenification

Dispose ( ) : void

Cleanup and close

GetConfigAsync ( ) : Task

Request the configuration from the hub

GetCurrentActivityAsync ( ) : Task

Send message to HarmonyHub to request current activity Result is parsed by OnIq based on ClientCommandType

SendCommandAsync ( string deviceId, string command, bool press = true, int timestamp = null ) : System.Threading.Task

Send message to HarmonyHub to request to press a button Result is parsed by OnIq based on ClientCommandType

SendKeyPressAsync ( string deviceId, string command, int timespan = 100 ) : System.Threading.Task

Send a message that a button was pressed Result is parsed by OnIq based on ClientCommandType

StartActivityAsync ( string activityId ) : System.Threading.Task

Send message to HarmonyHub to start a given activity Result is parsed by OnIq based on ClientCommandType

SwapAuthToken ( string userAuthToken ) : Task

Send message to HarmonyHub with UserAuthToken, wait for SessionToken

TurnOffAsync ( ) : System.Threading.Task

Send message to HarmonyHub to request to turn off all devices

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

Метод Описание
ErrorHandler ( object sender, Exception ex ) : void

Help with login errors

FireAndForgetAsync ( Document document, int waitTimeout = 50 ) : System.Threading.Task

Send a document, ignore the response (but wait shortly for a possible error)

GenerateIq ( Document document ) : agsXMPP.protocol.client.IQ

Generate an IQ for the supplied Document

GetData ( agsXMPP.protocol.client.IQ iq ) : string

Get the data from the IQ response object

HarmonyClient ( string host, string token, int port = 5222 ) : System

Constructor with standard settings for a new HarmonyClient

OnIqResponseHandler ( object sender, agsXMPP.protocol.client.IQ iq ) : void

Lookup the TaskCompletionSource for the IQ message and try to set the result.

OnLoginHandler ( object sender ) : void

Handle login by completing the _loginTaskCompletionSource

OnMessage ( object sender, agsXMPP.protocol.client.Message message ) : void

Handle incomming messages

RequestResponseAsync ( Document document, int timeout = 2000 ) : Task

Send a document, await the response and return it

SaslStartHandler ( object sender, SaslEventArgs saslEventArgs ) : void

Configure Sasl not to use auto and PLAIN for authentication

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

Create() публичный статический Метод

Create a HarmonyClient with pre-authenticated token
public static Create ( string host, string token, int port = 5222 ) : HarmonyClient
host string IP or hostname
token string token which is created via an authentication via myharmony.com
port int Port to connect to, 5222 is the default
Результат HarmonyClient

Create() публичный статический Метод

Create a harmony client via myharmony.com authenification
public static Create ( string host, string username, string password, int port = 5222 ) : Task
host string IP or hostname
username string myharmony.com username (email)
password string myharmony.com password
port int Port to connect to, default 5222
Результат Task

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

Cleanup and close
public Dispose ( ) : void
Результат void

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

Request the configuration from the hub
public GetConfigAsync ( ) : Task
Результат Task

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

Send message to HarmonyHub to request current activity Result is parsed by OnIq based on ClientCommandType
public GetCurrentActivityAsync ( ) : Task
Результат Task

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

Send message to HarmonyHub to request to press a button Result is parsed by OnIq based on ClientCommandType
public SendCommandAsync ( string deviceId, string command, bool press = true, int timestamp = null ) : System.Threading.Task
deviceId string string with the ID of the device
command string string with the command for the device
press bool true for press, false for release
timestamp int Timestamp for the command, e.g. send a press with 0 and a release with 100
Результат System.Threading.Task

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

Send a message that a button was pressed Result is parsed by OnIq based on ClientCommandType
public SendKeyPressAsync ( string deviceId, string command, int timespan = 100 ) : System.Threading.Task
deviceId string string with the ID of the device
command string string with the command for the device
timespan int The time between the press and release, default 100ms
Результат System.Threading.Task

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

Send message to HarmonyHub to start a given activity Result is parsed by OnIq based on ClientCommandType
public StartActivityAsync ( string activityId ) : System.Threading.Task
activityId string string
Результат System.Threading.Task

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

Send message to HarmonyHub with UserAuthToken, wait for SessionToken
public SwapAuthToken ( string userAuthToken ) : Task
userAuthToken string
Результат Task

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

Send message to HarmonyHub to request to turn off all devices
public TurnOffAsync ( ) : System.Threading.Task
Результат System.Threading.Task