本文整理汇总了C++中CNetClient::GetCurrState方法的典型用法代码示例。如果您正苦于以下问题:C++ CNetClient::GetCurrState方法的具体用法?C++ CNetClient::GetCurrState怎么用?C++ CNetClient::GetCurrState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CNetClient
的用法示例。
在下文中一共展示了CNetClient::GetCurrState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnClientPerformance
bool CNetClient::OnClientPerformance(void *context, CFsmEvent* event)
{
// Performance statistics for one or multiple clients
ENSURE(event->GetType() == (uint)NMT_CLIENT_PERFORMANCE);
CNetClient* client = (CNetClient*)context;
JSContext* cx = client->GetScriptInterface().GetContext();
if (client->GetCurrState() == NCS_LOADING)
return true;
CClientPerformanceMessage* message = (CClientPerformanceMessage*)event->GetParamRef();
std::vector<CClientPerformanceMessage::S_m_Clients> &clients = message->m_Clients;
// Display warnings for other clients with bad ping
for (size_t i = 0; i < clients.size(); ++i)
{
if (clients[i].m_MeanRTT < DEFAULT_TURN_LENGTH_MP || clients[i].m_GUID == client->m_GUID)
continue;
JS::RootedValue msg(cx);
client->GetScriptInterface().Eval("({ 'type':'netwarn', 'warntype': 'client-latency' })", &msg);
client->GetScriptInterface().SetProperty(msg, "guid", clients[i].m_GUID);
client->GetScriptInterface().SetProperty(msg, "meanRTT", clients[i].m_MeanRTT);
client->PushGuiMessage(msg);
}
return true;
}
示例2: OnClientTimeout
bool CNetClient::OnClientTimeout(void *context, CFsmEvent* event)
{
// Report the timeout of some other client
ENSURE(event->GetType() == (uint)NMT_CLIENT_TIMEOUT);
CNetClient* client = (CNetClient*)context;
JSContext* cx = client->GetScriptInterface().GetContext();
if (client->GetCurrState() == NCS_LOADING)
return true;
CClientTimeoutMessage* message = (CClientTimeoutMessage*)event->GetParamRef();
JS::RootedValue msg(cx);
client->GetScriptInterface().Eval("({ 'type':'netwarn', 'warntype': 'client-timeout' })", &msg);
client->GetScriptInterface().SetProperty(msg, "guid", std::string(message->m_GUID));
client->GetScriptInterface().SetProperty(msg, "lastReceivedTime", message->m_LastReceivedTime);
client->PushGuiMessage(msg);
return true;
}