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


C++ CNetClient::GetCurrState方法代码示例

本文整理汇总了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;
}
开发者ID:joselitofilho,项目名称:0ad,代码行数:30,代码来源:NetClient.cpp

示例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;
}
开发者ID:joselitofilho,项目名称:0ad,代码行数:22,代码来源:NetClient.cpp


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