public override BasePacket GetPacket(int op, byte[] data)
 {
     if (Rev.ContainsKey(op))
     {
         try
         {
             GsClientPacket obj = (GsClientPacket)Rev[op].ClonePacket();
             obj.PacketData = data;
             return(obj);
         }
         catch (Exception ex)
         {
             ProjectData.SetProjectError(ex);
             Exception ex2 = ex;
             log.Error((object)ex2);
             BasePacket result = null;
             ProjectData.ClearProjectError();
             return(result);
         }
     }
     if (ChatConfig.UNKNOWN_PACKET)
     {
         log.DebugFormat("收到来自游戏服务器的未知数据包, 操作码:0x{0}\r\n{1}", (object)Conversion.Hex(op).PadLeft(2, '0'), (object)Util.ToHex(data, 0));
     }
     return(null);
 }
Beispiel #2
0
 private void ReceivePacketThread()
 {
     while (readPackets.Count != 0)
     {
         GsClientPacket gsClientPacket = readPackets.Dequeue();
         using MemoryStream input = new MemoryStream(gsClientPacket.PacketData);
         gsClientPacket.Rbuf      = new BinaryReader(input);
         gsClientPacket.Client    = this;
         if (gsClientPacket.Read())
         {
             gsClientPacket.Run();
         }
     }
     IsRead = false;
 }