private bool TCPCmdPacketEvent(object sender) { TCPInPacket tcpInPacket = sender as TCPInPacket; TCPOutPacket tcpOutPacket = null; GameServerClient client = null; bool result2; if (!this.gameServerClients.TryGetValue(tcpInPacket.CurrentSocket, out client)) { LogManager.WriteLog(LogTypes.Error, string.Format("未建立会话或会话已关闭: {0},{1}, 关闭连接", (TCPGameServerCmds)tcpInPacket.PacketCmdID, Global.GetSocketRemoteEndPoint(tcpInPacket.CurrentSocket))); result2 = false; } else { TCPProcessCmdResults result = TCPCmdHandler.ProcessCmd(client, this.DBMgr, this.tcpOutPacketPool, (int)tcpInPacket.PacketCmdID, tcpInPacket.GetPacketBytes(), tcpInPacket.PacketDataSize, out tcpOutPacket); if (result == TCPProcessCmdResults.RESULT_DATA && null != tcpOutPacket) { this.socketListener.SendData(tcpInPacket.CurrentSocket, tcpOutPacket); } else if (result == TCPProcessCmdResults.RESULT_FAILED) { LogManager.WriteLog(LogTypes.Error, string.Format("解析并执行命令失败: {0},{1}, 关闭连接", (TCPGameServerCmds)tcpInPacket.PacketCmdID, Global.GetSocketRemoteEndPoint(tcpInPacket.CurrentSocket))); return(false); } result2 = true; } return(result2); }
public static TCPProcessCmdResults ProcessCmd(GameServerClient client, DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket) { tcpOutPacket = null; TCPProcessCmdResults result; if (nID != 11001) { result = TCPCmdDispatcher.getInstance().dispathProcessor(client, nID, data, count); } else { result = TCPCmdHandler.ProcessOnlineServerHeartCmd(dbMgr, pool, nID, data, count, out tcpOutPacket); } return(result); }