private void Send(Packet packet, bool encrypt) { var buffer = packet.Writer.GetBuffer(); if (encrypt) { buffer = _crypt.Encrypt(packet.Writer.GetBuffer()); } var bufferLength = buffer.Length; var length = (ushort)(bufferLength + 2); // Length includes itself try { if (ServerMain.Instance.LogEnabled[0] && ServerMain.Instance.IPBlacklist.Contains(this?.EndPoint?.Address?.ToString()) == false) { Log.Info("[{2}] Attempting to send {0} to {1}.", Packets.GetName(packet.Id), this?._tcp?.Client?.RemoteEndPoint?.ToString(), this?.Character?.Name); } _ns.Write(BitConverter.GetBytes(length), 0, 2); // Depend on what I want to do _ns.Write(buffer, 0, bufferLength); this.TimeSinceLastPacket = DateTime.Now.Ticks; } catch (Exception ex) { KillConnection(ex); } }
public void Send(Packet packet) { var buffer = packet.Writer.GetBuffer(); if (_crypt != null) { buffer = _crypt.Encrypt(packet.Writer.GetBuffer()); } var bufferLength = buffer.Length; var length = (ushort)(bufferLength + 2); // Length includes itself try { _ns.Write(BitConverter.GetBytes(length), 0, 2); // Depend on what I want to do _ns.Write(buffer, 0, bufferLength); } catch (Exception ex) { Console.Error.WriteLine(ex); } }