CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::NetworkDataReceiver Class Referenceabstract

Callback interface for asynchronous (push) delivery of received bytes. More...

#include <NetworkConnections.h>

Public Member Functions

 NetworkDataReceiver ()
virtual bool receiveData (char *data, uint32 size, NetworkConnection *con)=0
 Called when data has been read from the socket.
virtual bool registerError (uint16 error, NetworkConnection *con)=0
 Called when the connection encounters an error (e.g.

Detailed Description

Callback interface for asynchronous (push) delivery of received bytes.

When a NetworkDataReceiver is attached to a connection at connect() time, the connection runs its own reader thread and pushes raw bytes to receiveData() as they arrive, instead of the owner pulling data with NetworkConnection::receive(). Protocol parsing on top of these raw bytes is the receiver's responsibility.

Note
Callbacks arrive on the connection's internal reader thread.

Definition at line 417 of file NetworkConnections.h.

Constructor & Destructor Documentation

◆ NetworkDataReceiver()

cmlabs::NetworkDataReceiver::NetworkDataReceiver ( )
inline

Definition at line 419 of file NetworkConnections.h.

Member Function Documentation

◆ receiveData()

virtual bool cmlabs::NetworkDataReceiver::receiveData ( char * data,
uint32 size,
NetworkConnection * con )
pure virtual

Called when data has been read from the socket.

Parameters
dataPointer to the received bytes; ownership transfers to the receiver (allocated with new[]; delete with delete[]).
sizeNumber of valid bytes at data.
conThe connection the data arrived on (not owned).
Returns
true if the data was taken/handled.

◆ registerError()

virtual bool cmlabs::NetworkDataReceiver::registerError ( uint16 error,
NetworkConnection * con )
pure virtual

Called when the connection encounters an error (e.g.

peer disconnect).

Parameters
errorOne of the NETWORKERROR_* codes.
conThe connection reporting the error (not owned).
Returns
true if the error was handled.

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