public static int DecompressPacket(byte[] Packet, ref byte[] DecompressedBytes, int DecompressionBufferLength) { int headerLength = Compression.ComputeDataHeaderLength(Packet); int num = Compression.ComputeDataLength(Packet); if (num == 0) { return(0); } return(Compression.DecompressDataContent(Packet, headerLength, num, ref DecompressedBytes, DecompressionBufferLength)); }
public override void DataReceived(int TotalLength) { checked { switch (this.SocketType) { case SockType.Chat: if (TotalLength >= 4) { byte[] array = new byte[5]; this.PeekData(ref array, 4); if (array[0] == 255) { short num = (short)BitConverter.ToUInt16(array, 2); byte[] packet = new byte[(int)(num + 1)]; if (TotalLength >= (int)num) { this.GetData(ref packet, (int)num); this.ParsePacket(packet); } } } break; case SockType.Realm: if (TotalLength >= 3) { byte[] array = new byte[4]; this.PeekData(ref array, 3); short num = (short)BitConverter.ToUInt16(array, 0); byte[] packet = new byte[(int)(num + 1)]; if (TotalLength >= (int)num) { this.GetData(ref packet, (int)num); this.ParsePacket(packet); } } break; case SockType.Game: if (TotalLength >= 2) { byte[] array = new byte[2]; if (this.Firstpacket) { this.GetData(ref array, 2); this.Firstpacket = false; this.ParsePacket(array); return; } this.PeekData(ref array, 2); short num2 = (short)Compression.ComputeDataLength(array); if (TotalLength >= (int)num2) { byte[] packet2 = new byte[(int)(num2 + 1)]; this.GetData(ref packet2, (int)num2); int num3 = 24567; byte[] buffer = new byte[num3 + 1]; int num4 = Compression.DecompressPacket(packet2, ref buffer, num3); if (num4 != 0) { List <byte[]> list = Compression.SplitPackets(buffer, num4); if (list != null) { foreach (var packet in list) { this.ParsePacket(packet); } } } } } break; } } }