本文整理汇总了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;
}
}
}
}
示例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);
}
}