kmMqtt 0.0.1
MQTT Client Library
Loading...
Searching...
No Matches
kmMqtt::IWebSocket Class Referenceabstract

Interface for a WebSocket connection. More...

#include <IWebSocket.h>

Inheritance diagram for kmMqtt::IWebSocket:
kmMqtt::DefaultWebsocket

Public Member Functions

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

Detailed Description

Interface for a WebSocket connection.

Member Function Documentation

◆ close()

virtual bool kmMqtt::IWebSocket::close ( )
pure virtualnoexcept

Close the WebSocket connection.

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

Implemented in kmMqtt::DefaultWebsocket.

◆ connect()

virtual bool kmMqtt::IWebSocket::connect ( const mqtt::Address & address)
pure virtualnoexcept

Connect to a WebSocket server.

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

Implemented in kmMqtt::DefaultWebsocket.

◆ getLastCloseCode()

virtual int kmMqtt::IWebSocket::getLastCloseCode ( ) const
pure virtualnoexcept

Get the last close code and reason.

Returns
The last close code and reason.

Implemented in kmMqtt::DefaultWebsocket.

◆ getLastCloseReason()

virtual const char * kmMqtt::IWebSocket::getLastCloseReason ( ) const
pure virtualnoexcept

Get the last close reason.

Returns
The last close reason.

Implemented in kmMqtt::DefaultWebsocket.

◆ getLastError()

virtual int kmMqtt::IWebSocket::getLastError ( ) const
pure virtualnoexcept

Get the last error code.

Returns
The last error code.

Implemented in kmMqtt::DefaultWebsocket.

◆ isConnected()

virtual bool kmMqtt::IWebSocket::isConnected ( ) const
pure virtualnoexcept

Check if the WebSocket is connected.

Returns
True if connected, false otherwise.

Implemented in kmMqtt::DefaultWebsocket.

◆ send()

virtual int kmMqtt::IWebSocket::send ( const ByteBuffer & data)
pure virtualnoexcept

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.

Implemented in kmMqtt::DefaultWebsocket.

◆ setOnConnectCallback()

virtual void kmMqtt::IWebSocket::setOnConnectCallback ( OnConnectCallback callback)
pure virtualnoexcept

Set the callback for when the WebSocket connects.

Parameters
callbackThe callback function.

Implemented in kmMqtt::DefaultWebsocket.

◆ setOnDisconnectCallback()

virtual void kmMqtt::IWebSocket::setOnDisconnectCallback ( OnDisconnectCallback callback)
pure virtualnoexcept

Set the callback for when the WebSocket disconnects.

Parameters
callbackThe callback function.

Implemented in kmMqtt::DefaultWebsocket.

◆ setOnErrorCallback()

virtual void kmMqtt::IWebSocket::setOnErrorCallback ( OnErrorCallback callback)
pure virtualnoexcept

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

Parameters
callbackThe callback function.

Implemented in kmMqtt::DefaultWebsocket.

◆ setOnRecvdCallback()

virtual void kmMqtt::IWebSocket::setOnRecvdCallback ( OnRecvdCallback callback)
pure virtualnoexcept

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

Parameters
callbackThe callback function.

Implemented in kmMqtt::DefaultWebsocket.


The documentation for this class was generated from the following file:
  • D:/Dev/Repos/kmMqtt/include/public/kmMqtt/Interfaces/IWebSocket.h