本文整理汇总了C++中NetClient::SetHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ NetClient::SetHandler方法的具体用法?C++ NetClient::SetHandler怎么用?C++ NetClient::SetHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetClient
的用法示例。
在下文中一共展示了NetClient::SetHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConnectToServer
bool ServerConnectMgr::ConnectToServer(int32 nServerID,int32 nServerType,const char arrHost[32],int32 nPort,NetMsgEnter fEnter,NetMsgOn fMsg,NetMsgExit fExit)
{
NetClientInfoVecterType::iterator it = m_vecNetClientInfo.begin();
NetClientInfoVecterType::iterator itEnd = m_vecNetClientInfo.end();
for (; it != itEnd;++it)
{
if((*it)->nServerID == nServerID)
return false;
}
NetClient* pNetClient = new NetClient();
pNetClient->SetAddress(arrHost, nPort);
pNetClient->SetHandler(fEnter,fMsg,fExit);
pNetClient->Start();
NetClientInfo* pConn = new NetClientInfo();
pConn->pNetClient = pNetClient;
pConn->nServerID = nServerID;
pConn->nServerType = nServerType;
m_vecNetClientInfo.push_back(pConn);
return true;
}
示例2: ClientInit
void ClientInit()
{
InitNetMsg();
for (int32 i = 0; i < MAX_CLIENT_COUNT; ++i)
{
NetClient* gNetClient = new NetClient();
gNetClient->SetAddress("127.0.0.1", 9900);
gNetClient->SetHandler(OnNetMsgEnter, OnNetMsg, OnNetMsgExit);
gNetClient->Start();
ClientPlayer* gPlayer = new ClientPlayer();
gPlayer->SetSocket(gNetClient->GetSocket());
ClientPlayerMgr::Instance()->AddSocket(gNetClient,gPlayer);
}
//命令调试
//gGameCommond.Init(gNetClient->GetSocket());
//GameCommand::CommandHelp();
}