本文整理汇总了C++中NetConnection::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ NetConnection::SetName方法的具体用法?C++ NetConnection::SetName怎么用?C++ NetConnection::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetConnection
的用法示例。
在下文中一共展示了NetConnection::SetName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NetJoinRequestCallback
void NetJoinRequestCallback(NetSender* sender, NetMessage& msg) {
//do nothing
ConsolePrintString("\nNetJoinRequestCallback => ");
BinaryBufferParser bp(&msg.messageBuffer[0], msg.curSize);
std::string otherName = bp.ReadNextString();
ConsolePrintString(otherName);
if (NetworkSystem::s_gameSession->CanAddNewConn()) {
Byte nextConnIndex = NetworkSystem::s_gameSession->GetNextJoinableConnIndex();
NetworkSystem::s_gameSession->AddConnection(*sender->addr, 0xff, "client_"+ShortToString(nextConnIndex)+"(O.o)((_ | __ | _");
//sender->conn = NetworkSystem::s_gameSession->FindConnectionInMap(nextConnIndex);
NetConnection* newClientConnPtr = NetworkSystem::s_gameSession->FindConnectionInMap(0xff);
if (newClientConnPtr) {
NetMessage* joinAcceptMsg = new NetMessage(EN_MSG_ID_JOIN_ACCEPT);
Byte myMaxConns = NetworkSystem::s_gameSession->GetMaxConnections();
joinAcceptMsg->WRITE_BYTES(myMaxConns);
joinAcceptMsg->WRITE_BYTES(nextConnIndex);
if (NetworkSystem::s_gameSession->m_connSelf) {
Byte myConnIndex = NetworkSystem::s_gameSession->m_connSelf->GetConnIndex();
joinAcceptMsg->WRITE_BYTES(myConnIndex);
//joinAcceptMsg->WriteMessageData(&myConnIndex, SIZE_OF(myConnIndex));
//joinAcceptMsg->WriteMessageData(&std::string(AllocLocalHostName() + "__(O.o)((_|__|_\0"), SIZE_OF(std::string));
std::string hostNameString = AllocLocalHostName();
joinAcceptMsg->WRITE_BYTES(hostNameString);
}//end of if my info exists
//doing sender->conn causes system to spam new conns
newClientConnPtr->SendNetMessage(*joinAcceptMsg);
//newClientConnPtr->SetConnIndex(0xff);
newClientConnPtr->SetName("client_" + ShortToString(nextConnIndex) + "(O.o)((_ | __ | _");
}
}
else {
NetMessage* joinDenyMsg = new NetMessage(EN_MSG_ID_JOIN_DENY);
NetworkSystem::s_gameSession->SendNetMessage(*joinDenyMsg);
}
}