本文整理汇总了C++中EventHandler::AddEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventHandler::AddEvent方法的具体用法?C++ EventHandler::AddEvent怎么用?C++ EventHandler::AddEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventHandler
的用法示例。
在下文中一共展示了EventHandler::AddEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testStagingDir
PE_PD_IT() :
testStagingDir(""),
testDownloadDir(""),
testPrintDataDir(""),
eventHandler(),
nullI2cDevice(),
motor(nullI2cDevice),
projector(nullI2cDevice),
printerStatusQueue(),
commandPipe(),
timer1(),
timer2(),
timer3(),
timer4(),
printEngine(false, motor, projector, printerStatusQueue, timer1, timer2,
timer3, timer4),
commandInterpreter(&printEngine),
ui()
{
// Assemble PrintEngine, EventHandler, and CommandInterpreter so UICommands
// coming in through the command pipe are handled by the print engine
// Subscribe UIProxy to status updates so status updates are available for assertion
eventHandler.AddEvent(UICommand, &commandPipe);
eventHandler.AddEvent(PrinterStatusUpdate, &printerStatusQueue);
eventHandler.Subscribe(UICommand, &commandInterpreter);
eventHandler.Subscribe(PrinterStatusUpdate, &ui);
printEngine.Begin();
}
示例2: main
int main(int argc, char ** argv)
{
std::cout << "Battlefield 3 TuxNet (Rcon Service) Rev. " << REVISION << " :: Copyright 2009-2013 (c) Plain-Solution.de" << endl;
try
{
// settings.ini lesen
boost::property_tree::ptree pt;
boost::property_tree::ini_parser::read_ini(string(argv[0]).append(".ini"), pt);
std::cout << "BF3 Server: " << pt.get<string>("Server.Host") << ":" << pt.get<string>("Server.Port") << endl;
////
fstream pidfile(string(argv[0]).append(".pid"), ios::out);
if(!pidfile)
throw string("Could not write pidfile");
pidfile << getpid() << endl;
pidfile.close();
RconConnection * rcon = new RconConnection( pt.get<string>("Server.Host"), pt.get<string>("Server.Port"), pt.get<string>("Server.Password") );
rcon->Login();
rcon->EnableEvents();
string msg = "[BF3 TuxNet Rev. ";
msg += REVISION;
msg += "] by Plain-Solution.de";
rcon->sendRequest(createWords("admin.say", msg.c_str(), "all"));
EventHandler * eventHandler = new EventHandler(rcon, &pt);
thread eventThread([eventHandler]() {
eventHandler->DoWork();
});
while(true)
{
try
{
TextRconPacket response = rcon->getResponse();
if(eventHandler->needResponse != 0 && response.isValid() && response.m_isResponse && eventHandler->needResponse == response.m_sequence)
{
eventHandler->response = new TextRconPacket(response);
eventHandler->needResponse = 0;
}
if(response.isValid() && !response.m_isResponse && response.m_originatedOnServer)
eventHandler->AddEvent(response);
}
catch(string e)
{
eventHandler->out(e, EventHandler::OUT_TYPE::ERR);
}
}
eventHandler->Disable();
eventThread.join();
}
catch(exception & e)
{
_out(e.what(), EventHandler::OUT_TYPE::ERR);
}
catch(string & e)
{
_out(e, EventHandler::OUT_TYPE::ERR);
}
remove(string(argv[0]).append(".pid").c_str());
return 0;
}