本文整理汇总了C++中CClient::SendMsg方法的典型用法代码示例。如果您正苦于以下问题:C++ CClient::SendMsg方法的具体用法?C++ CClient::SendMsg怎么用?C++ CClient::SendMsg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClient
的用法示例。
在下文中一共展示了CClient::SendMsg方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SendMsg
void CClientMgr::SendMsg(int32 clientid, Msg *pMsg)
{
if (clientid > 0)
{
CClient *cl = FindClientByClientID(clientid);
if (cl)
{
cl->SendMsg(pMsg);
}
}
else
{
std::list<CClient*>::iterator _Iter = m_ClientList.begin();
for (; _Iter != m_ClientList.end(); ++_Iter)
(*_Iter)->SendMsg(pMsg);
}
}
示例2: OnMsgTransmit
void CClient::OnMsgTransmit(unsigned short wMsgId, const char *pMsg)
{
if (m_strAccount.length() == 0)
{
LOGDebug("account is empty.");
return;
}
SEsp8266Info *pEspInfo = CEsp8266Mgr::getMe().Find(m_strAccount);
if (nullptr == pEspInfo)
{
LOGDebug("nullptr == pEspInfo[m_strAccount:" + m_strAccount + "]");
return;
}
CClient *pSendClient = nullptr;
CClient *pToClient = nullptr;
if (this == pEspInfo->pClientApp)
{
pSendClient = pEspInfo->pClientApp;
pToClient = pEspInfo->pClientEsp;
}
else if (this == pEspInfo->pClientEsp)
{
pSendClient = pEspInfo->pClientEsp;
pToClient = pEspInfo->pClientApp;
}
else
{
LOGDebug("OnMsgTransmit error.[m_strAccount:" + m_strAccount + "]");
return;
}
if (nullptr == pToClient)
{
LOGDebug("nullptr == pToClient.[m_strAccount:" + m_strAccount + "]");
return;
}
pToClient->SendMsg(wMsgId, pMsg);
LOGDebug("Account[" + m_strAccount + "] transmit message[msgid:" + wMsgId + "].");
}