当前位置: 首页>>代码示例>>C++>>正文


C++ EventHandler::AddEvent方法代码示例

本文整理汇总了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();
    }
开发者ID:IceForgTW,项目名称:ember-firmware,代码行数:30,代码来源:PE_PD_IT.cpp

示例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;
}
开发者ID:DeadHunter,项目名称:TuxNet,代码行数:74,代码来源:main.cpp


注:本文中的EventHandler::AddEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。