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


C++ Msg::Type方法代码示例

本文整理汇总了C++中Msg::Type方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::Type方法的具体用法?C++ Msg::Type怎么用?C++ Msg::Type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Msg的用法示例。


在下文中一共展示了Msg::Type方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: update

void Game::update(double delta)
{
	Msg* msg = peek();
	while(msg)
	{
		msg = pop();
		if(msg)
		{
			MsgType type = msg->Type();
			switch(type)
			{
			case ENTITY_GHOST_SPAWN:
				msgSpawnGhost(msg);
				break;
			case INPUT_KEYBOARD_MSG:
				msgKeyboard(msg);
				break;
			case GAME_OVER:
				msgGameOver(msg);
				break;
			case GAME_WON:
				msgGameWon(msg);
				break;
			default:
				throw 0; //temp
				break;
			}
		}
	}
}
开发者ID:CaterHatterPillar,项目名称:PACMANIA,代码行数:30,代码来源:Game.cpp

示例2: Logic

//! application logic
void ActiveState::Logic (void)
{
	CliApp::Instance()->Logger() << ends << LOG_DEBUG
		<< "Active state logic" << endl;

	CliApp::Instance()->Logger() << ends << LOG_INFO 
		<< "Continuing" << endl;

	//! send a keepalive message to the server
	CliApp::Instance()->Server()->Send(*m_poContinueMsg);
	try 
	{
		//! try to get a response from the server
		Msg oRecvMsg = CliApp::Instance()->Server()->Recv();

		//! if the server does not respond positively
		if (oRecvMsg.Type() != CONTINUING )
		{
			//! the application should change state to connecting
			CliApp::Instance()->Logger() << ends << LOG_INFO 
				<< "ACTIVE => CONN" << endl;
			CliApp::Instance()->StateTrans(CONN);
		}
		else
		{
			//! otherwise, we're still active
			CliApp::Instance()->Logger() << ends << LOG_INFO
				<< "ACTIVE" << endl;
			//! sleep for some time before the next keepalive
			sleep(m_i32PollInterval);
		}
	} 
	catch (TimeoutException& roExc) 
	{ 
		//! if the server does not respond for some time
		CliApp::Instance()->Logger() << ends << LOG_DEBUG
			<< "Timeout in continue" << endl;
	}
	catch (SyscallException& roExc)
	{
		//! if we are interrupted before the server can respond
		CliApp::Instance()->Logger() << ends << LOG_CRIT
			<< "Syscall failed in ACTIVE: "
			<< roExc.what() << endl;
		CliApp::Instance()->StateTrans(ERROR);
	}
}
开发者ID:codeparity,项目名称:linc-daemon,代码行数:48,代码来源:ActiveState.cpp


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