Low-Level C# SDK  v1.3.0
Loading...
Searching...
No Matches
WeArt.Core.WeArtClient Class Reference

Network client used to send and receive message to/from the hardware middleware. This class is meant to be used internally but can also be used by developers who want to communicate with the hardware in a direct way. More...

Public Types

enum  MessageType { MessageSent , MessageReceived }
 Possible message types. More...
 
enum  ErrorType { ConnectionError , SendMessageError , ReceiveMessageError }
 Possible error types. More...
 

Public Member Functions

Task Start (TrackingType trackingType=TrackingType.WEART_HAND)
 Establishes a connection to the middleware and send the StartFromClientMessage
 
async Task< bool > Stop ()
 Stops the middleware and the established connection.
 
void StartCalibration ()
 Starts the calibration procedure.
 
void StopCalibration ()
 Stops the calibration procedure.
 
void StartRawData ()
 Asks the middleware to start sending raw data events to the sdk.
 
void StopRawData ()
 Tells the middleware to stop sending raw data events.
 
async Task< T > SendAndWaitForMessage< T > (IWeArtMessage message, int timeoutMs)
 Send the given message to the middleware and waits for a given type of response within the given timeout.
 
async Task< T > SendAndWaitForMessage< T > (IWeArtMessage message, Func< T, bool > predicate, int timeoutMs)
 Send the given message to the middleware and waits for a response (with a given condition applied) within the given timeout.
 
async Task< T > WaitForMessage< T > (int timeoutMs)
 Waits for any message with the given type for the given timeout.
 
async Task< T > WaitForMessage< T > (Func< T, bool > predicate, int timeoutMs)
 Waits for any message with the given type and condition for the given timeout.
 
void SendMessage (IWeArtMessage message)
 Sends a message to the middleware.
 

Properties

bool IsConnected [get]
 True if a connection to the middleware has been established.
 
string IpAddress [get, set]
 The IP address of the middleware network endpoint.
 
int Port [get, set]
 The port of the middleware network endpoint.
 

Events

Action< bool > OnConnectionStatusChanged
 Called when the connection has been established (true) and when it is closed (false)
 
Action< MessageType, IWeArtMessage > OnMessage
 Called when a IWeArtMessage is sent or received.
 
Action< MessageType, string > OnTextMessage
 Called when a IWeArtMessage is serialized or deserialized.
 
Action< ErrorType, Exception > OnError
 Called when an error occurs.
 
Action< HandSideOnCalibrationStart
 Called when the calibration procedure starts.
 
Action< HandSideOnCalibrationFinish
 Called when the calibration procedure ends.
 
Action< HandSideOnCalibrationResultSuccess
 Called when the calibration procedure is successful.
 
Action< HandSideOnCalibrationResultFail
 Called when the calibration procedure faild.
 
Action< MiddlewareStatusUpdateOnMiddlewareStatusUpdate
 Called when a status update is received from the middleware.
 

Detailed Description

Network client used to send and receive message to/from the hardware middleware. This class is meant to be used internally but can also be used by developers who want to communicate with the hardware in a direct way.

Member Enumeration Documentation

◆ ErrorType

Possible error types.

Enumerator
ConnectionError 
SendMessageError 
ReceiveMessageError 

◆ MessageType

Possible message types.

Enumerator
MessageSent 
MessageReceived 

Member Function Documentation

◆ SendAndWaitForMessage< T >() [1/2]

async Task< T > WeArt.Core.WeArtClient.SendAndWaitForMessage< T > ( IWeArtMessage  message,
Func< T, bool >  predicate,
int  timeoutMs 
)
inline

Send the given message to the middleware and waits for a response (with a given condition applied) within the given timeout.

Template Parameters
TType of the message to wait for
Parameters
messageMessage to send before waiting
predicateThe condition the received message must pass to be considered
timeoutMsTime to wait for the given message type
Returns
The received response message
Exceptions
TimeoutExceptionThrown when the correct message is not received withih the given timeout

◆ SendAndWaitForMessage< T >() [2/2]

async Task< T > WeArt.Core.WeArtClient.SendAndWaitForMessage< T > ( IWeArtMessage  message,
int  timeoutMs 
)
inline

Send the given message to the middleware and waits for a given type of response within the given timeout.

Template Parameters
TType of the message to wait for
Parameters
messageMessage to send before waiting
timeoutMsTime to wait for the given message type
Returns
The received response message
Exceptions
TimeoutExceptionThrown when the correct message is not received withih the given timeout

◆ SendMessage()

void WeArt.Core.WeArtClient.SendMessage ( IWeArtMessage  message)
inline

Sends a message to the middleware.

Parameters
messageThe message

◆ Start()

Task WeArt.Core.WeArtClient.Start ( TrackingType  trackingType = TrackingType::WEART_HAND)
inline

Establishes a connection to the middleware and send the StartFromClientMessage

Returns
The task running during the entire life of the network connection

◆ StartCalibration()

void WeArt.Core.WeArtClient.StartCalibration ( )
inline

Starts the calibration procedure.

◆ StartRawData()

void WeArt.Core.WeArtClient.StartRawData ( )
inline

Asks the middleware to start sending raw data events to the sdk.

◆ Stop()

async Task< bool > WeArt.Core.WeArtClient.Stop ( )
inline

Stops the middleware and the established connection.

Returns
True if the middleware was stopped correctly and the connection closed, false otherwise

◆ StopCalibration()

void WeArt.Core.WeArtClient.StopCalibration ( )
inline

Stops the calibration procedure.

◆ StopRawData()

void WeArt.Core.WeArtClient.StopRawData ( )
inline

Tells the middleware to stop sending raw data events.

◆ WaitForMessage< T >() [1/2]

async Task< T > WeArt.Core.WeArtClient.WaitForMessage< T > ( Func< T, bool >  predicate,
int  timeoutMs 
)
inline

Waits for any message with the given type and condition for the given timeout.

Template Parameters
TType of the message to wait
Parameters
predicateCondition that the message must fullfill to be considered ok
timeoutMsTimeout to wait for the correct message
Returns
The received message
Exceptions
TimeoutExceptionThrown when the correct message is not received withih the given timeout

◆ WaitForMessage< T >() [2/2]

async Task< T > WeArt.Core.WeArtClient.WaitForMessage< T > ( int  timeoutMs)
inline

Waits for any message with the given type for the given timeout.

Template Parameters
TType of the message to wait
Parameters
timeoutMsTimeout to wait for the correct message
Returns
The received message
Exceptions
TimeoutExceptionThrown when the correct message is not received withih the given timeout

Property Documentation

◆ IpAddress

string WeArt.Core.WeArtClient.IpAddress
getset

The IP address of the middleware network endpoint.

◆ IsConnected

bool WeArt.Core.WeArtClient.IsConnected
get

True if a connection to the middleware has been established.

◆ Port

int WeArt.Core.WeArtClient.Port
getset

The port of the middleware network endpoint.

Event Documentation

◆ OnCalibrationFinish

Action<HandSide> WeArt.Core.WeArtClient.OnCalibrationFinish

Called when the calibration procedure ends.

◆ OnCalibrationResultFail

Action<HandSide> WeArt.Core.WeArtClient.OnCalibrationResultFail

Called when the calibration procedure faild.

◆ OnCalibrationResultSuccess

Action<HandSide> WeArt.Core.WeArtClient.OnCalibrationResultSuccess

Called when the calibration procedure is successful.

◆ OnCalibrationStart

Action<HandSide> WeArt.Core.WeArtClient.OnCalibrationStart

Called when the calibration procedure starts.

◆ OnConnectionStatusChanged

Action<bool> WeArt.Core.WeArtClient.OnConnectionStatusChanged

Called when the connection has been established (true) and when it is closed (false)

◆ OnError

Action<ErrorType, Exception> WeArt.Core.WeArtClient.OnError

Called when an error occurs.

◆ OnMessage

Action<MessageType, IWeArtMessage> WeArt.Core.WeArtClient.OnMessage

Called when a IWeArtMessage is sent or received.

◆ OnMiddlewareStatusUpdate

Action<MiddlewareStatusUpdate> WeArt.Core.WeArtClient.OnMiddlewareStatusUpdate

Called when a status update is received from the middleware.

◆ OnTextMessage

Action<MessageType, string> WeArt.Core.WeArtClient.OnTextMessage

Called when a IWeArtMessage is serialized or deserialized.


The documentation for this class was generated from the following file: