public void Send(PacketOut packet) { try { if (!Connected) { return; } Log.WriteLine(LogType.Network, "Sending packet: {0}", packet.packetId); if (!Connected) { return; } Byte[] Data = packet.ToArray(); int Length = Data.Length; byte[] Packet = new byte[2 + Length]; Packet[0] = (byte)(Length >> 8); Packet[1] = (byte)(Length & 0xff); Data.CopyTo(Packet, 2); mCrypt.Encrypt(Packet, 0, 6); //While writing this part of code I had a strange feeling of Deja-Vu or whatever it's called :> Log.WriteLine(LogType.Packet, "{0}", packet.ToHex()); mSocket.Send(Packet); } catch (Exception ex) { Log.WriteLine(LogType.Error, "Exception Occured"); Log.WriteLine(LogType.Error, "Message: {0}", ex.Message); Log.WriteLine(LogType.Error, "Stacktrace: {0}", ex.StackTrace); } }
public void Send(PacketOut packet) { if (Connected) { Log.WriteLine(LogType.Network, "Sending packet {0}. Length: {1}", packet.packetId.ToString(), packet.Lenght()); Log.WriteLine(LogType.Packet, "{0}", packet.ToHex()); Byte[] Data = packet.ToArray(); mSocket.Send(Data); } }