NDEVR
API Documentation
AdaptiveWebClient

WebSocket client that implements the NDEVR communication protocol over a QWebSocket. More...

Inheritance diagram for AdaptiveWebClient:
[legend]

Public Member Functions

 AdaptiveWebClient (QObject *parent=nullptr)
 Constructs the WebSocket client.
virtual uint08 bytesAvailable (void *socket) override
 Returns the number of bytes available for reading.
void * connectTo (const NDEVRServerInfo &info) override
 Establishes a connection to the specified server.
void connectToServer (const StringView &host, uint04 port, bool secure)
 Initiates a WebSocket connection to the specified host and port.
virtual void disconnectFrom (void *socket) override
 Disconnects from the specified socket.
virtual bool isOpen (void *socket=nullptr) const override
 Checks whether the socket is currently connected.
virtual uint08 rx (void *socket, NDEVRDataPacket &packet) override
 Receives data from the socket into a packet.
virtual uint08 tx (void *socket, NDEVRDataPacket &packet, uint08 size) override
 Transmits packet data through the socket.
void updateWindowSize (NDEVRConnectionData &state) override
 Updates the protocol window size for flow control.
virtual void wait (const TimeSpan &span, LogPtr log=nullptr) override
 Waits for the specified time span, processing events.

Protected Attributes

bool m_is_open_received = false
 Whether the connected signal has been received.
QTimer m_reconnect_timer
 Timer for automatic reconnection attempts.
QTimer m_send_timer
 Timer for periodic send buffer flushing.
QWebSocket * m_server_socket
 The underlying WebSocket.
bool m_should_be_open = false
 Whether the connection should be open.

Detailed Description

WebSocket client that implements the NDEVR communication protocol over a QWebSocket.

Provides automatic reconnection, buffered sending, and integrates with the NDEVRCommunicationLogic framework for binary message-based data transfer.

Definition at line 14 of file AdaptiveWebClient.h.

Constructor & Destructor Documentation

◆ AdaptiveWebClient()

AdaptiveWebClient::AdaptiveWebClient ( QObject * parent = nullptr)
explicit

Constructs the WebSocket client.

Parameters
[in]parentOptional parent QObject.

Member Function Documentation

◆ bytesAvailable()

virtual uint08 AdaptiveWebClient::bytesAvailable ( void * socket)
overridevirtual

Returns the number of bytes available for reading.

Parameters
[in]socketThe socket to check.
Returns
The number of bytes available.

◆ connectTo()

void * AdaptiveWebClient::connectTo ( const NDEVRServerInfo & info)
override

Establishes a connection to the specified server.

Parameters
[in]infoThe server information to connect to.
Returns
An opaque pointer to the connection socket.

◆ connectToServer()

void AdaptiveWebClient::connectToServer ( const StringView & host,
uint04 port,
bool secure )

Initiates a WebSocket connection to the specified host and port.

Parameters
[in]hostThe hostname or IP address to connect to.
[in]portThe port number.
[in]secureWhether to use a secure (wss://) connection.

◆ disconnectFrom()

virtual void AdaptiveWebClient::disconnectFrom ( void * socket)
overridevirtual

Disconnects from the specified socket.

Parameters
[in]socketThe socket to disconnect.

◆ isOpen()

virtual bool AdaptiveWebClient::isOpen ( void * socket = nullptr) const
overridevirtual

Checks whether the socket is currently connected.

Parameters
[in]socketThe socket to check, or nullptr for the default.
Returns
True if the connection is open.

◆ rx()

virtual uint08 AdaptiveWebClient::rx ( void * socket,
NDEVRDataPacket & packet )
overridevirtual

Receives data from the socket into a packet.

Parameters
[in]socketThe socket to receive from.
[in]packetThe packet buffer to fill.
Returns
The number of bytes received.

◆ tx()

virtual uint08 AdaptiveWebClient::tx ( void * socket,
NDEVRDataPacket & packet,
uint08 size )
overridevirtual

Transmits packet data through the socket.

Parameters
[in]socketThe socket to send through.
[in]packetThe packet data to send.
[in]sizeThe number of bytes to send.
Returns
The number of bytes sent.

◆ updateWindowSize()

void AdaptiveWebClient::updateWindowSize ( NDEVRConnectionData & state)
override

Updates the protocol window size for flow control.

Parameters
[in]stateThe connection state to update.

◆ wait()

virtual void AdaptiveWebClient::wait ( const TimeSpan & span,
LogPtr log = nullptr )
overridevirtual

Waits for the specified time span, processing events.

Parameters
[in]spanThe duration to wait.
[in]logOptional log for progress reporting.

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