コード例 #1
0
 public TCPProcessCmdResults OnResponse(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
 {
     tcpOutPacket = null;
     try
     {
         string[] fields = new UTF8Encoding().GetString(data, 0, count).Split(new char[]
         {
             ':'
         });
         if (fields == null || fields.Length <= 2)
         {
             return(TCPProcessCmdResults.RESULT_FAILED);
         }
         int        roleId = Convert.ToInt32(fields[0]);
         int        index  = Convert.ToInt32(fields[1]);
         GameClient client = GameManager.ClientMgr.FindClient(socket);
         if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleId))
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleId), null, true);
             return(TCPProcessCmdResults.RESULT_FAILED);
         }
         if (index < 0 || index >= 2)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("角色返回敏感数据索引错误,roleid={0}, rolename={1}, index={2}", roleId, client.ClientData.RoleName, index), null, true);
             return(TCPProcessCmdResults.RESULT_FAILED);
         }
         lock (client.InterestingData)
         {
             InterestingData.Item item = client.InterestingData.itemArray[index];
             if (item != null)
             {
                 item.LastResponseMs = TimeUtil.NOW();
                 item.ResponseCount++;
                 if (index == 0)
                 {
                     this._CheckSpeed(client, item, fields);
                 }
             }
         }
     }
     catch
     {
     }
     return(TCPProcessCmdResults.RESULT_OK);
 }
コード例 #2
0
        public static TCPProcessCmdResults ProcessMarryAutoReject(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false)), null, true);
                return(TCPProcessCmdResults.RESULT_FAILED);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), fields.Length), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                int        roleID     = Convert.ToInt32(fields[0]);
                int        autoReject = Convert.ToInt32(fields[1]);
                GameClient client     = GameManager.ClientMgr.FindClient(socket);
                if (KuaFuManager.getInstance().ClientCmdCheckFaild(nID, client, ref roleID))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket, false), roleID), null, true);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
                MarryResult result = MarryLogic.MarryAutoReject(client, autoReject);
                string      strcmd = string.Format("{0}:{1}", (int)result, client.ClientData.MyMarriageData.byAutoReject);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessMarryPartyCancel", false, false);
            }
            return(TCPProcessCmdResults.RESULT_FAILED);
        }
コード例 #3
0
ファイル: MarriageLogic.cs プロジェクト: chenchungit/ky
        public static TCPProcessCmdResults ProcessMarryDivorce(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket)));
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 2)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                int roleID      = Convert.ToInt32(fields[0]);
                int divorceType = Convert.ToInt32(fields[1]);

                GameClient client = GameManager.ClientMgr.FindClient(socket);
                if (null == client || client.ClientData.RoleID != roleID)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}",
                                                                      (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID));
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }

                MarryResult result = MarryDivorce(client, (MarryDivorceType)divorceType);

                string strcmd = string.Format("{0}", (int)result);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "ProcessMarryPartyCancel", false);
            }

            return(TCPProcessCmdResults.RESULT_FAILED);
        }