Base class for network UDP server clients.
More...
#include <tdme/network/udpserver/UDPServerClient.h>
|
virtual | ~UDPServerClient () |
| public destructor, should only be called implicitly by Reference::releaseReference() More...
|
|
virtual void | onRequest (stringstream *frame, const uint32_t messageId, const uint8_t retries)=0 |
| To be overwritten with a request handler, will be called from worker. More...
|
|
virtual void | onClose ()=0 |
|
virtual void | onFrameReceived (stringstream *frame, const uint32_t messageId=0, const uint8_t retries=0) |
| Event, which will be called if frame has been received, defaults to worker thread pool. More...
|
|
void | close () |
| Shuts down this network client. More...
|
|
void | init () |
| initiates this network client More...
|
|
virtual void | onRequest (stringstream *frame, const uint32_t messageId, const uint8_t retries)=0 |
| To be overwritten with a request handler, will be called from worker. More...
|
|
virtual void | onInit ()=0 |
|
virtual void | onClose ()=0 |
|
virtual void | onCustom (const string &type)=0 |
|
virtual void | onFrameReceived (stringstream *frame, const uint32_t messageId=0, const uint8_t retries=0)=0 |
| Event, which will be called if frame has been received, defaults to worker thread pool. More...
|
|
virtual void | close ()=0 |
| Shuts down this network client. More...
|
|
Base class for network UDP server clients.
- Author
- Andreas Drewke
Definition at line 30 of file UDPServerClient.h.
◆ MessageMapSafe
◆ UDPServerClient()
UDPServerClient |
( |
const uint32_t |
clientId, |
|
|
const std::string & |
ip, |
|
|
const unsigned int |
port |
|
) |
| |
public constructor should be called in any subclass of UDPNetworkServer
- Parameters
-
clientId | client id |
ip | ip |
port | port |
Definition at line 27 of file UDPServerClient.cpp.
◆ ~UDPServerClient()
public destructor, should only be called implicitly by Reference::releaseReference()
Definition at line 42 of file UDPServerClient.cpp.
◆ cleanUpSafeMessages()
void cleanUpSafeMessages |
( |
| ) |
|
|
private |
◆ close()
◆ createFrame()
stringstream * createFrame |
( |
| ) |
|
|
static |
Creates a frame to be used with send.
- Returns
- frame to be send
Definition at line 76 of file UDPServerClient.cpp.
◆ fireEvent()
void fireEvent |
( |
const string & |
type | ) |
|
◆ getClientId()
const uint32_t getClientId |
( |
| ) |
|
◆ getIp()
const string & getIp |
( |
| ) |
const |
|
virtual |
◆ getKey()
const string & getKey |
( |
| ) |
const |
|
virtual |
◆ getPort()
const unsigned int getPort |
( |
| ) |
const |
|
virtual |
◆ getRetryTime()
uint64_t getRetryTime |
( |
const uint8_t |
retries | ) |
|
◆ getServer()
◆ init()
◆ onClose()
◆ onFrameReceived()
void onFrameReceived |
( |
stringstream * |
frame, |
|
|
const uint32_t |
messageId = 0 , |
|
|
const uint8_t |
retries = 0 |
|
) |
| |
|
protectedvirtual |
Event, which will be called if frame has been received, defaults to worker thread pool.
- Parameters
-
frame | frame |
messageId | message id (upd server only) |
retries | retries (udp server only) |
Implements ServerClient.
Definition at line 188 of file UDPServerClient.cpp.
◆ onRequest()
virtual void onRequest |
( |
stringstream * |
frame, |
|
|
const uint32_t |
messageId, |
|
|
const uint8_t |
retries |
|
) |
| |
|
protectedpure virtual |
To be overwritten with a request handler, will be called from worker.
- Parameters
-
frame | frame |
messageId | message id |
retries | retries |
Implements ServerClient.
◆ processSafeMessage()
bool processSafeMessage |
( |
const uint32_t |
messageId | ) |
|
Checks if message has already been processed and sends an acknowlegdement to client / safe client messages.
- Parameters
-
Definition at line 111 of file UDPServerClient.cpp.
◆ send()
void send |
( |
stringstream * |
frame, |
|
|
bool |
safe = true , |
|
|
bool |
deleteFrame = true |
|
) |
| |
Sends a frame to client, takes over ownership of frame.
- Parameters
-
frame | frame data |
safe | safe, requires ack and retransmission |
deleteFrame | delete frame |
Definition at line 83 of file UDPServerClient.cpp.
◆ sendConnected()
◆ setKey()
const bool setKey |
( |
const string & |
key | ) |
|
|
virtual |
sets the clients identification key
- Parameters
-
&key | client identification key |
- Returns
- if setting the key was succesful
Implements ServerClient.
Definition at line 65 of file UDPServerClient.cpp.
◆ shutdown()
◆ UDPServer
◆ UDPServerIOThread
◆ clientId
◆ ioThread
◆ ip
◆ messageMapSafe
◆ messageMapSafeMutex
Mutex messageMapSafeMutex |
|
private |
◆ MESSAGESSAFE_KEEPTIME
const uint64_t MESSAGESSAFE_KEEPTIME = 5000L |
|
staticprivate |
◆ port
◆ server
◆ shutdownRequested
volatile bool shutdownRequested |
|
private |
The documentation for this class was generated from the following files: