34#include <NDEVR/Dictionary.h>
35#include <NDEVR/String.h>
36#include <NDEVR/PasswordString.h>
37#include "NDEVRDataPacket.h"
38#include <NDEVR/LogPtr.h>
44 struct NDEVRConnectionData
84 class NDEVRSERVERCLIENT_API NDEVRCommunicationLogic
88 NDEVRCommunicationLogic();
90 virtual ~NDEVRCommunicationLogic() {};
94 void addConnection(
void* socket,
const StringView&
id);
97 void removeConnection(
void* socket);
100 virtual void updateWindowSize(NDEVRConnectionData& state);
104 bool sendAndReceiveData(NDEVRConnectionData& state);
107 void addListener(PacketListener* listener);
111 void changeConnectionState(
void* socket,
bool is_connected);
114 void removeListener(PacketListener* listener) { m_listeners.removeElement(listener); }
118 virtual void* connectTo(
const NDEVRServerInfo& info) = 0;
121 virtual void disconnectFrom(
void* socket) = 0;
125 bool readRxData(NDEVRConnectionData& state);
129 virtual void sendMessage(
void* target, NDEVRDataPacket&& data);
133 const NDEVRConnectionData* connectionData(
void* target);
137 virtual void wait(
const TimeSpan& span, LogPtr log =
nullptr) = 0;
140 const NDEVRServerInfo& connectionInfo()
const {
return m_connection_info; }
144 virtual bool isOpen(
void* socket =
nullptr)
const = 0;
150 virtual uint08 rx(
void* socket, NDEVRDataPacket& packet) = 0;
156 virtual uint08 tx(
void* socket, NDEVRDataPacket& packet, uint08 max_size) = 0;
160 virtual uint08 bytesAvailable(
void* socket) = 0;
162 Buffer<PacketListener*> m_listeners;
163 Dictionary<void*, NDEVRConnectionData*> m_connections;
164 NDEVRServerInfo m_connection_info;
Interface for objects that wish to receive NDEVR packet events and connection state changes.
virtual void onConnectionChanged(void *socket, bool is_connected)=0
Called when a connection's state changes.
virtual void onReceive(NDEVRConnectionData &state)=0
Called when a complete packet has been received.
When passwords are used inside the NDEVR engine, we don't want them logged or visible.
The core String class for the NDEVR API.
The primary namespace for the NDEVR SDK.
uint16_t uint02
-Defines an alias representing a 2 byte, unsigned integer -Can represent exact integer values 0 throu...
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Holds the state of a single NDEVR network connection, including transmit and receive packets.
String connection_id
Unique identifier for this connection.
NDEVRDataPacket tx_message
Outgoing data packet being assembled or sent.
void * socket
Opaque socket handle for the connection.
uint04 window_size
Transmission window size in bytes.
NDEVRDataPacket rx_message
Incoming data packet being received.
Contains the address, credentials, and security flag needed to connect to an NDEVR server.
String address
Server hostname or IP address.
PasswordString password
Password for authentication.
uint02 port
Server port number.
String username
Username for authentication.
bool secure
Whether to use a secure (TLS/SSL) connection.