Esempio n. 1
0
 public override BasePacket GetPacket(int op, byte[] data)
 {
     if (Rev.ContainsKey(op))
     {
         try
         {
             LsClientPacket obj = (LsClientPacket)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 (LoginConfig.UNKNOWN_PACKET)
     {
         log.DebugFormat("收到来自客户端的未知数据包, 操作码:0x{0}\r\n{1}", (object)Conversion.Hex(op).PadLeft(2, '0'), (object)Util.ToHex(data, 0));
     }
     return(null);
 }
Esempio n. 2
0
 private void ReceivePacketThread()
 {
     while (readPackets.Count != 0)
     {
         LsClientPacket lsClientPacket = readPackets.Dequeue();
         using MemoryStream input = new MemoryStream(lsClientPacket.PacketData);
         lsClientPacket.Rbuf      = new BinaryReader(input);
         lsClientPacket.Client    = this;
         if (lsClientPacket.Read())
         {
             lsClientPacket.Run();
         }
     }
     IsRead = false;
 }