Skip to content

BaseServerWorkerUDP

juhgiyo edited this page Nov 14, 2012 · 2 revisions

BaseServerWorkerUDP Usage

  • Idea of the "BaseServerWorkerUDP" is communicating the packets with the client whatever the way you prefer.

Linking

// SomeServerWorkerUDP.h
#include "epse.h"
using namespace epl;
using namespace epse;

Server Worker Declaration Example

// SomeServerWorkerUDP.h
class SomeServerWorkerUDP:public BaseServerWorkerUDP
{
public:
   SomeServerWorkerUDP();
   SomeServerWorkerUDP(const SomeServerWorkerUDP& b);
   virtual ~SomeServerWorkerUDP();
   SomeServerWorkerUDP & operator=(const SomeServerWorkerUDP&b)
   {
      if(this!=&b)
      {
         BaseServerWorkerUDP::operator =(b);
      }
      return *this;
   }
protected:
   virtual BasePacketParser* createNewPacketParser();;
};

Server Worker Implementation Example

// SomeServerWorkerUDP.cpp
#include "SomeServerWorkerUDP.h"

SomeServerWorkerUDP::SomeServerWorkerUDP():BaseServerWorkerUDP()
{
}

SomeServerWorkerUDP::SomeServerWorkerUDP(const SomeServerWorkerUDP& b):BaseServerWorkerUDP(b)
{
}

SomeServerWorkerUDP::~SomeServerWorkerUDP()
{
}

BasePacketParser* SomeServerWorkerUDP::createNewPacketParser()
{
   return EP_NEW SomePacketParser();
}
  • * Note that SomePacketParser object will be created/destroyed automatically by BaseServerWorker. For the details of SomePacketParser class, see BasePacketParser

Server Worker Receive Packet Details

  • When Server Worker receives a packet, the Server Worker will create new PacketParser object for each packet, it receives.
  • PacketParser will be run as a new thread, and the parsing will take place in the newly created thread.
  • For more detail, please see BasePacketParser
Something went wrong with that request. Please try again.