kmMqtt 0.0.1
MQTT Client Library
Loading...
Searching...
No Matches
kmMqtt::DefaultWebsocket Class Reference
Inheritance diagram for kmMqtt::DefaultWebsocket:
kmMqtt::IWebSocket

Public Member Functions

bool connect (const mqtt::Address &address) noexcept override
 Connect to a WebSocket server.
int send (const ByteBuffer &data) noexcept override
 Send data over the WebSocket connection.
bool close () noexcept override
 Close the WebSocket connection.
void tick () noexcept override
 SDK calls this periodically in-case the WebSocket implementation needs to perform any tick tasks.
bool isConnected () const noexcept override
 Check if the WebSocket is connected.
int getLastError () const noexcept override
 Get the last error code.
int getLastCloseCode () const noexcept override
 Get the last close code and reason.
const char * getLastCloseReason () const noexcept override
 Get the last close reason.
void setOnConnectCallback (OnConnectCallback callback) noexcept override
 Set the callback for when the WebSocket connects.
void setOnDisconnectCallback (OnDisconnectCallback callback) noexcept override
 Set the callback for when the WebSocket disconnects.
void setOnRecvdCallback (OnRecvdCallback callback) noexcept override
 Set the callback for when data is received over the WebSocket.
void setOnErrorCallback (OnErrorCallback callback) noexcept override
 Set the callback for when an error occurs on the WebSocket.

Member Function Documentation

◆ close()

bool kmMqtt::DefaultWebsocket::close ( )
overridevirtualnoexcept

Close the WebSocket connection.

Returns
True if the operation to request a close proccessed correctly, false otherwise.

Implements kmMqtt::IWebSocket.

◆ connect()

bool kmMqtt::DefaultWebsocket::connect ( const mqtt::Address & address)
overridevirtualnoexcept

Connect to a WebSocket server.

Parameters
addressThe address to connect to.
Returns
True if the operation to request a connect proccessed correctly, false otherwise.

Implements kmMqtt::IWebSocket.

◆ getLastCloseCode()

int kmMqtt::DefaultWebsocket::getLastCloseCode ( ) const
overridevirtualnoexcept

Get the last close code and reason.

Returns
The last close code and reason.

Implements kmMqtt::IWebSocket.

◆ getLastCloseReason()

const char * kmMqtt::DefaultWebsocket::getLastCloseReason ( ) const
overridevirtualnoexcept

Get the last close reason.

Returns
The last close reason.

Implements kmMqtt::IWebSocket.

◆ getLastError()

int kmMqtt::DefaultWebsocket::getLastError ( ) const
overridevirtualnoexcept

Get the last error code.

Returns
The last error code.

Implements kmMqtt::IWebSocket.

◆ isConnected()

bool kmMqtt::DefaultWebsocket::isConnected ( ) const
overridevirtualnoexcept

Check if the WebSocket is connected.

Returns
True if connected, false otherwise.

Implements kmMqtt::IWebSocket.

◆ send()

int kmMqtt::DefaultWebsocket::send ( const ByteBuffer & data)
overridevirtualnoexcept

Send data over the WebSocket connection.

Partial sends are managed internally by the SDK, socket implementation does not need to handle them.

Parameters
dataThe data to send. Socket must manage its own partial sends.
Returns
The number of bytes sent, or a negative error code on failure.

Implements kmMqtt::IWebSocket.

◆ setOnConnectCallback()

void kmMqtt::DefaultWebsocket::setOnConnectCallback ( OnConnectCallback callback)
inlineoverridevirtualnoexcept

Set the callback for when the WebSocket connects.

Parameters
callbackThe callback function.

Implements kmMqtt::IWebSocket.

◆ setOnDisconnectCallback()

void kmMqtt::DefaultWebsocket::setOnDisconnectCallback ( OnDisconnectCallback callback)
inlineoverridevirtualnoexcept

Set the callback for when the WebSocket disconnects.

Parameters
callbackThe callback function.

Implements kmMqtt::IWebSocket.

◆ setOnErrorCallback()

void kmMqtt::DefaultWebsocket::setOnErrorCallback ( OnErrorCallback callback)
inlineoverridevirtualnoexcept

Set the callback for when an error occurs on the WebSocket.

Parameters
callbackThe callback function.

Implements kmMqtt::IWebSocket.

◆ setOnRecvdCallback()

void kmMqtt::DefaultWebsocket::setOnRecvdCallback ( OnRecvdCallback callback)
inlineoverridevirtualnoexcept

Set the callback for when data is received over the WebSocket.

Parameters
callbackThe callback function.

Implements kmMqtt::IWebSocket.


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