Exemple #1
0
 public virtual void SendPacket(BasePacket pak)
 {
     checked
     {
         try
         {
             int i = 0;
             int num;
             for (byte[] packetData = pak.PacketData; i < packetData.Length; i += num)
             {
                 num = _socket.Send(packetData, i, packetData.Length - i, SocketFlags.None);
                 if (num <= 0)
                 {
                     Disconnect();
                 }
             }
         }
         catch (Exception ex)
         {
             ProjectData.SetProjectError(ex);
             Exception ex2 = ex;
             Disconnect();
             ProjectData.ClearProjectError();
         }
     }
 }
Exemple #2
0
 protected virtual bool ReadPacket(ref List <BasePacket> packets)
 {
     read.Position = 0L;
     if (read.Length < 2)
     {
         return(false);
     }
     checked
     {
         try
         {
             byte[] array = new byte[2];
             read.Read(array, 0, 2);
             short num = BitConverter.ToInt16(array, 0);
             if (read.Length < num)
             {
                 return(false);
             }
             short op = (short)read.ReadByte();
             array = new byte[num - 4 + 1];
             read.Read(array, 0, array.Length);
             BasePacket packet = Handle.GetPacket(op, array);
             if (!Information.IsNothing(packet))
             {
                 packets.Add(packet);
             }
             if (read.Length - read.Position > 2)
             {
                 array = new byte[(int)(read.Length - read.Position - 1) + 1];
                 read.Read(array, 0, array.Length);
                 read.Dispose();
                 ReSet();
                 read.Write(array, 0, array.Length);
                 return(true);
             }
         }
         catch (Exception ex)
         {
             ProjectData.SetProjectError(ex);
             Exception ex2 = ex;
             log.Error((object)ex2);
             ProjectData.ClearProjectError();
         }
         ReSet();
         return(false);
     }
 }
Exemple #3
0
 protected abstract void PacketHandle(BasePacket pak);
Exemple #4
0
 private void _Lambda_0024__25_002D0(BasePacket p)
 {
     PacketHandle(p);
 }
Exemple #5
0
 protected abstract void AddClient(BasePacket packet);