public static void Release(Packet p) { if (p != null) p.Release(); }
public static void Release(ref Packet p) { if (p != null) p.Release(); p = null; }
public static Packet SetStatic(Packet p) { p.SetStatic(); return p; }
public static Packet Acquire(Packet p) { p.Acquire(); return p; }
public virtual void Send(Packet p) { if (mSocket == null || mBlockAllPackets) { p.OnSend(); return; } PacketSendProfile prof = PacketSendProfile.Acquire(p.GetType()); int length; byte[] buffer = p.Compile(out length); if (buffer == null) { CConsole.ErrorLine("{0}: null buffer send, disconnecting...", this); Dispose(); return; } if (buffer.Length <= 0 || length <= 0) { p.OnSend(); return; } if (prof != null) { prof.Start(); } if (mEncoder != null) { mEncoder.EncodeOutgoingPacket(this, ref buffer, ref length); } try { Int16 pID = BitConverter.ToInt16(buffer, 0); CConsole.DebugLine("{0}: sending Packet 0x{1:X4}", this, pID); mSocket.BeginSend(buffer, 0, length, SocketFlags.None, mOnSend, mSocket); } catch (Exception ex) { Dispose(false); throw; } p.OnSend(); if (prof != null) { prof.Finish(length); } }