28 ApplicationServerClient::ApplicationServerClient(
const uint32_t clientId,
const string& ip,
const unsigned int port) :
29 UDPServerClient(clientId, ip, port), networkPacketsMutex(
"wsserverclient-networkpacketsmutex") {
33 Console::println(
"ApplicationServerClient::~ApplicationServerClient()");
45 while (packet->
getPosition() < UDPPacket::PACKET_MAX_SIZE) {
50 auto logicTypeId = packet->
getInt();
67 Console::println(
"Initiated connection with '" +
getIp() +
":" + to_string(
getPort()) +
"', sending key");
71 Console::println(
"Closed connection with '" +
getIp() +
":" + to_string(
getPort()) +
"'");
75 Console::println(
"Custom event '" + type +
"' with '" +
getIp() +
":" + to_string(
getPort()) +
"'");
Application server client.
vector< LogicNetworkPacket > & getNetworkPackets()
virtual ~ApplicationServerClient()
Destructor.
virtual void onClose()
On close.
Mutex & getNetworkPacketsMutex()
Mutex networkPacketsMutex
virtual void onInit()
On init.
vector< LogicNetworkPacket > networkPackets
virtual void onCustom(const string &type)
On custom.
void onRequest(const UDPPacket *packet, const uint32_t messageId, const uint8_t retries)
On request.
void setSender(const string &sender)
Set sender.
uint32_t getInt() const
Get a int from packet.
uint16_t getPosition() const
Get position.
bool getBool() const
Get a bool from packet.
uint8_t getByte() const
Get a byte from packet.
Base class for network UDP server clients.
const string & getKey() const
Client identification key.
const uint16_t getPort() const
returns client port
const string & getIp() const
returns client's ip
bool processSafeMessage(const uint32_t messageId)
Checks if message has already been processed and sends an acknowlegdement to client / safe client mes...
Base class for network UDP servers.
void unlock()
Unlocks this mutex.
void lock()
Locks the mutex, additionally mutex locks will block until other locks have been unlocked.
std::exception Exception
Exception base class.