Telegram Bot Api Client  0.6.1
Client_for_accessing_Telegram's_Bot_API
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JsonWebClient Class Reference

Public Member Functions

 JsonWebClient (Client *netClient, String host, int port, void *callBackObject, JWC_CALLBACK_MESSAGE_SIGNATURE, JWC_CALLBACK_ERROR_SIGNATURE)
 
bool fire (String commands[], int count)
 Executes a list of commands. More...
 
JwcClientState state ()
 Current state of the client. More...
 
bool loop ()
 Method to poll client processing. More...
 
bool stop ()
 Stops the client. More...
 

Private Member Functions

void reConnect ()
 Reconnects to host. More...
 
bool processHeader ()
 Process a header. More...
 
bool processJson ()
 Process JSON. More...
 

Private Attributes

JwcClientState State = JwcClientState::Unconnected
 
Client * NetClient
 
String Host
 
int Port
 
long ContentLength = JWC_BUFF_SIZE
 
bool HttpStatusOk = false
 
void * CallBackObject
 
 JWC_CALLBACK_MESSAGE_SIGNATURE
 
 JWC_CALLBACK_ERROR_SIGNATURE
 

Constructor & Destructor Documentation

◆ JsonWebClient()

JsonWebClient::JsonWebClient ( Client *  netClient,
String  host,
int  port,
void *  callBackObject,
JWC_CALLBACK_MESSAGE_SIGNATURE  ,
JWC_CALLBACK_ERROR_SIGNATURE   
)

Constructor, initializing all members

Parameters
netClienta object implementing Client interface to access the network. Using a Client implementing ssl feature will result in https otherwise http.
hostHost to connect to
portPort to connect to
callBackObjectObject passed to the callbacks, shall not be 0
JWC_CALLBACK_MESSAGE_SIGNATURECallback called on receiving a message / valid json data
JWC_CALLBACK_ERROR_SIGNATURECallback called on error while receiving

Member Function Documentation

◆ fire()

bool JsonWebClient::fire ( String  commands[],
int  count 
)

Executes a list of commands.

Parameters
[in]commands[]list of commands
[in]countof commands
Returns
Return true on success

Sends a list of commands to the server by calling println() for each command and flush() at the end of list. The commands shall follow the http protocol.

◆ loop()

bool JsonWebClient::loop ( )

Method to poll client processing.

Returns
True is an internal action was executed.

Method to poll client processing, shall be called in each main loop()

◆ processHeader()

bool JsonWebClient::processHeader ( )
private

Process a header.

Returns
Returns true while headers found in underlying Client

Read a header from NetClient and process it.

◆ processJson()

bool JsonWebClient::processJson ( )
private

Process JSON.

Returns
Returns true on success

Reads data from underlying Client and process it by ArduinoJSON

◆ reConnect()

void JsonWebClient::reConnect ( )
private

Reconnects to host.

Returns
Return nothing

Reconnects to host, skips open connection

◆ state()

JwcClientState JsonWebClient::state ( )

Current state of the client.

Returns
The current state as a JwcClientState

Make the current state of the client public accessible.

◆ stop()

bool JsonWebClient::stop ( )

Stops the client.

Returns
True

Stops the underlying client connection and reset client state to JwcClientState::unconnected

Member Data Documentation

◆ CallBackObject

void* JsonWebClient::CallBackObject
private

Object passed to the callbacks

◆ ContentLength

long JsonWebClient::ContentLength = JWC_BUFF_SIZE
private

Content length stored during header processing

◆ Host

String JsonWebClient::Host
private

Host to connect to

◆ HttpStatusOk

bool JsonWebClient::HttpStatusOk = false
private

Indicate if Http 200 Ok header was found

◆ JWC_CALLBACK_ERROR_SIGNATURE

JsonWebClient::JWC_CALLBACK_ERROR_SIGNATURE
private

Callback called on error while receiving

◆ JWC_CALLBACK_MESSAGE_SIGNATURE

JsonWebClient::JWC_CALLBACK_MESSAGE_SIGNATURE
private

Callback called on receiving a message / valid json data

◆ NetClient

Client* JsonWebClient::NetClient
private

Client used to access the net (depends on hardware)

◆ Port

int JsonWebClient::Port
private

Port to connect to

◆ State

JwcClientState JsonWebClient::State = JwcClientState::Unconnected
private

Current state of the client


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