private ByteArray HandlePacketData(ByteArray data) { //Discarded unreachable code: IL_01f8 int num = pendingPacket.Header.ExpectedLength - pendingPacket.Buffer.Length; bool flag = data.Length > num; ByteArray result = new ByteArray(data.Bytes); try { log.Debug("Handling Data: " + data.Length + ", previous state: " + pendingPacket.Buffer.Length + "/" + pendingPacket.Header.ExpectedLength); if (data.Length >= num) { pendingPacket.Buffer.WriteBytes(data.Bytes, 0, num); log.Debug("<<< Packet Complete >>>"); if (pendingPacket.Header.Encrypted) { packetEncrypter.Decrypt(pendingPacket.Buffer); } if (pendingPacket.Header.Compressed) { pendingPacket.Buffer.Uncompress(); } protocolCodec.OnPacketRead(pendingPacket.Buffer); fsm.ApplyTransition(PacketReadTransition.PacketFinished); } else { pendingPacket.Buffer.WriteBytes(data.Bytes); } if (flag) { data = ResizeByteArray(data, num, data.Length - num); return(data); } data = EMPTY_BUFFER; return(data); } catch (Exception ex) { log.Error("Error handling data: " + ex.Message + " " + ex.StackTrace); skipBytes = num; fsm.ApplyTransition(PacketReadTransition.InvalidData); return(result); } }
private void OnUDPData(byte[] bt) { //Discarded unreachable code: IL_014c ByteArray byteArray = new ByteArray(bt); if (byteArray.BytesAvailable < 4) { log.Warn("Too small UDP packet. Len: " + byteArray.Length); return; } if (sfs.Debug) { log.Info("UDP Data Read: " + DefaultObjectDumpFormatter.HexDump(byteArray)); } byte b = byteArray.ReadByte(); bool flag = (b & 0x20) > 0; bool flag2 = (b & 0x40) > 0; short num = byteArray.ReadShort(); if (num != byteArray.BytesAvailable) { log.Warn("Insufficient UDP data. Expected: " + num + ", got: " + byteArray.BytesAvailable); return; } byte[] buf = byteArray.ReadBytes(byteArray.BytesAvailable); ByteArray byteArray2 = new ByteArray(buf); if (flag2) { try { packetEncrypter.Decrypt(byteArray2); } catch (Exception ex) { log.Warn("UDP data decryption failed due to error: " + ex.Message + " " + ex.StackTrace); return; } } if (flag) { byteArray2.Uncompress(); } ISFSObject iSFSObject = SFSObject.NewFromBinaryData(byteArray2); if (iSFSObject.ContainsKey("h")) { if (!initSuccess) { StopTimer(); locked = false; initSuccess = true; Hashtable hashtable = new Hashtable(); hashtable["success"] = true; sfs.DispatchEvent(new SFSEvent(SFSEvent.UDP_INIT, hashtable)); } } else { sfs.GetSocketEngine().IoHandler.Codec.OnPacketRead(iSFSObject); } }