-
Notifications
You must be signed in to change notification settings - Fork 51
BaseServerWorker
juhgiyo edited this page Nov 15, 2012
·
4 revisions
- Idea of the "BaseServerWorker" is communicating the packets with the client whatever the way you prefer.
// SomeServerWorker.h
#include "epse.h"
using namespace epl;
using namespace epse;
// SomeServerWorker.h
class SomeServerWorker:public BaseServerWorker
{
public:
SomeServerWorker();
SomeServerWorker(const SomeServerWorker& b);
virtual ~SomeServerWorker();
SomeServerWorker & operator=(const SomeServerWorker&b)
{
if(this!=&b)
{
BaseServerWorker::operator =(b);
}
return *this;
}
protected:
virtual BasePacketParser* createNewPacketParser();;
};
// SomeServerWorker.cpp
#include "SomeServerWorker.h"
SomeServerWorker::SomeServerWorker():BaseServerWorker()
{
}
SomeServerWorker::SomeServerWorker(const SomeServerWorker& b):BaseServerWorker(b)
{
}
SomeServerWorker::~SomeServerWorker()
{
}
BasePacketParser* SomeServerWorker::createNewPacketParser()
{
return EP_NEW SomePacketParser();
}
-
- Note that SomePacketParser object will be created/destroyed automatically by BaseServerWorker. For the details of SomePacketParser class, see BasePacketParser
- 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