void GatewayPacketHandler::OnRecvExterPacket(int nSrcSessionID, Packet *poPacket, EXTER_HEADER& oHeader) { Gateway* poGateway = (Gateway*)g_poContext->GetService(); if (oHeader.nTarService == poGateway->GetServiceID() || oHeader.uCmd == NSCltSrvCmd::ppKeepAlive) { PacketProcIter iter = m_poExterPacketProcMap->find(oHeader.uCmd); if (iter != m_poExterPacketProcMap->end()) { (*(ExterPacketProc)(iter->second->pProc))(nSrcSessionID, poPacket, oHeader); } else { XLog(LEVEL_ERROR, "CMD:%d proc not found\n", oHeader.uCmd); } poPacket->Release(); } else { //Send to logic server if (oHeader.nTarService == 0) { oHeader.nTarService = poGateway->GetClientMgr()->GetClientLogicService(nSrcSessionID); if (oHeader.nTarService <= 0) { oHeader.nTarService = g_poContext->GetRandomLogic(); } if (oHeader.nTarService <= 0) { XLog(LEVEL_ERROR, "%s: Player logic server error\n", poGateway->GetServiceName()); poPacket->Release(); return; } } if (!NetAdapter::SendInner(oHeader.uCmd, poPacket, oHeader.nTarService, nSrcSessionID)) { XLog(LEVEL_ERROR, "%s: Send packet to router fail\n", poGateway->GetServiceName()); } } }