void CClientMgr::SendMsg(CClient *cl, google::protobuf::Message &pMsg, int32 maintype, int32 subtype) { assert(cl != nullptr); MessagePack pk; pk.Pack(&pMsg, maintype, subtype); cl->SendMsg(&pk); }
void CClientMgr::SendMsg(int32 clientid, google::protobuf::Message &pMsg, int32 maintype, int32 subtype) { if (clientid > 0) { CClient *cl = FindClientByClientID(clientid); if (cl) { MessagePack pk; pk.Pack(&pMsg, maintype, subtype); cl->SendMsg(&pk); } } else { MessagePack pk; pk.Pack(&pMsg, maintype, subtype); std::list<CClient*>::iterator _Iter = m_ClientList.begin(); for (; _Iter != m_ClientList.end(); ++_Iter) (*_Iter)->SendMsg(&pk); } }