public void Send(Packet p) { if (m_BlockAllPackets) { p.OnSend(); return; } PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)p.PacketID); DateTime start = (prof == null ? DateTime.MinValue : DateTime.Now); int length; byte[] buffer = p.Compile(m_CompressionEnabled, out length); if (buffer != null && buffer.Length > 0 && length > 0) { m_NetState.Send(buffer, length); } if (prof != null) { prof.Record(length, DateTime.Now - start); } p.OnSend(); }
public void Send(Packet p) { if (BlockAllPackets) { p.OnSend(); return; } var prof = PacketProfile.GetOutgoingProfile((byte)p.PacketID); var start = (prof == null ? DateTime.MinValue : DateTime.UtcNow); int length; var buffer = p.Compile(CompressionEnabled, out length); if (buffer != null && buffer.Length > 0 && length > 0) { UOSocket.Send(buffer, length); } if (prof != null) { prof.Record(length, DateTime.UtcNow - start); } p.OnSend(); }
public void Send(Packet p) { if (m_Socket == null || m_BlockAllPackets) { return; } PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)p.PacketID); DateTime start = (prof == null ? DateTime.MinValue : DateTime.Now); byte[] buffer = p.Compile(m_CompressionEnabled); if (buffer != null) { if (buffer.Length <= 0) { return; } int length = buffer.Length; if (m_Encoder != null) { m_Encoder.EncodeOutgoingPacket(this, ref buffer, ref length); } bool shouldBegin = false; lock (m_SendQueue) shouldBegin = (m_SendQueue.Enqueue(buffer, length)); if (shouldBegin) { int sendLength = 0; byte[] sendBuffer = m_SendQueue.Peek(ref sendLength); try { m_Socket.BeginSend(sendBuffer, 0, sendLength, SocketFlags.None, m_OnSend, null); m_Sending = true; //Console.WriteLine( "Send: {0}: Begin send of {1} bytes", this, sendLength ); } catch // ( Exception ex ) { //Console.WriteLine(ex); Dispose(false); } } if (prof != null) { prof.Record(length, DateTime.Now - start); } } else { Dispose(); } }
// Methods public Packet(int packetID) { this.m_PacketID = packetID; PacketProfile profile1 = PacketProfile.GetOutgoingProfile(((byte)packetID)); if (profile1 != null) { profile1.RegConstruct(); } }
public Packet(int packetID) { m_PacketID = packetID; PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)packetID); if (prof != null) { prof.RegConstruct(); } }
public Packet(int packetID, int length) { this.m_PacketID = packetID; this.m_Length = length; this.m_Stream = PacketWriter.CreateInstance(length); this.m_Stream.Write(((byte)packetID)); PacketProfile profile1 = PacketProfile.GetOutgoingProfile(((byte)packetID)); if (profile1 != null) { profile1.RegConstruct(); } }
public void Send(Packet p) { int num1; bool flag1; SendQueue queue1; if ((this.m_Socket == null) || this.m_BlockAllPackets) { return; } PacketProfile profile1 = PacketProfile.GetOutgoingProfile(((byte)p.PacketID)); DateTime time1 = ((profile1 == null) ? DateTime.MinValue : DateTime.Now); byte[] buffer1 = p.Compile(this.m_CompressionEnabled); if (buffer1 != null) { if (buffer1.Length <= 0) { return; } num1 = buffer1.Length; if (NetState.m_Encoder != null) { NetState.m_Encoder.EncodeOutgoingPacket(this, ref buffer1, ref num1); } flag1 = false; queue1 = this.m_SendQueue; lock (this.m_SendQueue) { flag1 = this.m_SendQueue.Enqueue(buffer1, num1); } if (flag1) { try { this.m_Socket.BeginSend(buffer1, 0, num1, SocketFlags.None, this.m_OnSend, null); } catch { this.Dispose(); } } if (profile1 == null) { return; } profile1.Record(num1, ((TimeSpan)(DateTime.Now - time1))); return; } this.Dispose(); }
public Packet(int packetID, int length) { m_PacketID = packetID; m_Length = length; m_Stream = PacketWriter.CreateInstance(length); // new PacketWriter( length ); m_Stream.Write((byte)packetID); PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)packetID); if (prof != null) { prof.RegConstruct(); } }
protected void Initialize(int packetID, int length) { m_PacketID = packetID; m_Length = length; if (m_Length > 0) { m_Stream = PacketWriter.CreateInstance(length); m_Stream.Write((byte)packetID); } PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)packetID); if (prof != null) { prof.RegConstruct(); } }
public void Send(Packet p) { if (m_Socket == null || m_BlockAllPackets) { p.OnSend(); return; } PacketProfile prof = PacketProfile.GetOutgoingProfile((byte)p.PacketID); DateTime start = (prof == null ? DateTime.MinValue : DateTime.Now); int length; byte[] buffer = p.Compile(m_CompressionEnabled, out length); if (buffer != null) { if (buffer.Length <= 0 || length <= 0) { p.OnSend(); return; } if (m_Encoder != null) { m_Encoder.EncodeOutgoingPacket(this, ref buffer, ref length); } SendEnqueueResult enqueueResult; lock (m_SendQueue) enqueueResult = (m_SendQueue.Enqueue(buffer, length)); if (enqueueResult == SendEnqueueResult.Begin) { int sendLength = 0; byte[] sendBuffer = m_SendQueue.Peek(ref sendLength); try { IAsyncResult res = m_Socket.BeginSend(sendBuffer, 0, sendLength, SocketFlags.None, m_OnSend, null); //Console.WriteLine( "Send: {0}: Begin send of {1} bytes", this, sendLength ); } catch // ( Exception ex ) { //Console.WriteLine(ex); Dispose(false); } } else if (enqueueResult == SendEnqueueResult.Overflow) { Console.WriteLine("Client: {0}: Too much data pending, disconnecting...", this); Dispose(false); } p.OnSend(); if (prof != null) { prof.Record(length, DateTime.Now - start); } } else { Dispose(); } }