43 lines
843 B
C++
43 lines
843 B
C++
|
#include "logging.h"
|
||
|
#include "netpkt.h"
|
||
|
#include "gameparser.h"
|
||
|
|
||
|
#define DEFAULT_TIMEOUT 180
|
||
|
|
||
|
GameParser::GameParser(Config& conf, RecvQueue& rxQueue, ModuleList& modList)
|
||
|
: rxQueue(rxQueue), modList(modList)
|
||
|
{
|
||
|
int interval = conf.getInteger("global", "game_timeout", DEFAULT_TIMEOUT);
|
||
|
TimerService::registerTimer(new Timer(new CleanupEvent(this), interval));
|
||
|
}
|
||
|
|
||
|
GameParser::~GameParser()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
int GameParser::execute(void* arg)
|
||
|
{
|
||
|
while (1) {
|
||
|
NetPkt* pkt = rxQueue.getPkt();
|
||
|
int ret = modList.parse(pkt, this);
|
||
|
switch (ret) {
|
||
|
case PKT_REJECT:
|
||
|
char buf[64];
|
||
|
pkt->show(buf, sizeof(buf));
|
||
|
LogSystem::log(LOG_DEBUG, "unknown Packet: %s", buf);
|
||
|
|
||
|
case PKT_ACCEPT:
|
||
|
delete pkt;
|
||
|
|
||
|
case PKT_ACCEPT_FREED:
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
void GameParser::cleanup()
|
||
|
{
|
||
|
LogSystem::log(LOG_DEBUG, "GameParser::cleanup()");
|
||
|
}
|