extern "C" int SendCommandByHandle(int worldId, int dest, const char* command) { int ret = 0; if (NULL != command) { SessionManager* pMgr = g_SessionManagers.Get(worldId); if (NULL != pMgr) { TcpSession* pSession = pMgr->GetSession(); if (NULL != pSession) { size_t cmdSize = strlen(command); MessageCommand msg; msg.m_Src = pMgr->MyHandle(); msg.m_Dest = dest; if (pSession->Send(reinterpret_cast<const char*>(&msg), sizeof(msg) - 1, command, cmdSize + 1)) { ret = 1; } } } } return ret; }
extern "C" int SendByHandle(int worldId, int dest, const void* data, int len) { int ret = 0; if (NULL != data) { SessionManager* pMgr = g_SessionManagers.Get(worldId); if (NULL != pMgr) { TcpSession* pSession = pMgr->GetSession(); if (NULL != pSession) { MessageTransmit msg; msg.m_Sequence = pMgr->SessionSequence(); msg.m_Src = pMgr->MyHandle(); msg.m_Dest = dest; if (msg.IsValid() && pSession->Send(reinterpret_cast<const char*>(&msg), sizeof(msg) - 1, reinterpret_cast<const char*>(data), len)) { pMgr->IncSessionSequence(); ret = 1; } } } } return ret; }