36 lines
644 B
C++
36 lines
644 B
C++
#include "logging.h"
|
|
#include "netpkt.h"
|
|
|
|
#include "gamescanner.h"
|
|
|
|
#define DEFAULT_SCAN_INTERVAL 30
|
|
|
|
GameScanner::GameScanner(Config& conf, ModuleList& modList, RecvQueue& rxQueue)
|
|
: modList(modList), rxQueue(rxQueue)
|
|
{
|
|
msock = new MultiSock(conf);
|
|
|
|
int interval = conf.getInteger("global", "scan_interval", DEFAULT_SCAN_INTERVAL);
|
|
TimerService::registerTimer(new Timer(new ScanEvent(*this), interval));
|
|
}
|
|
|
|
GameScanner::~GameScanner()
|
|
{
|
|
delete msock;
|
|
}
|
|
|
|
int GameScanner::execute(void* arg)
|
|
{
|
|
while (1) {
|
|
NetPkt* pkt = msock->recv();
|
|
if (pkt)
|
|
rxQueue.addPkt(pkt);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void GameScanner::scan()
|
|
{
|
|
modList.scan(msock);
|
|
}
|