public void PackingData(UInt64 Protocol, byte[] buffer) { lock (m_lock) { SendBuffer data = new SendBuffer(); data.buffer = new byte[4096]; data.size = 0; data.offset = sizeof(int); Buffer.BlockCopy(BitConverter.GetBytes(Protocol), 0, data.buffer, data.offset, sizeof(UInt64)); data.offset += sizeof(UInt64); data.size += sizeof(UInt64); if (buffer.Length != 0) { Buffer.BlockCopy(buffer, 0, data.buffer, data.offset, buffer.Length); data.size += buffer.Length; } Buffer.BlockCopy(BitConverter.GetBytes(data.size), 0, data.buffer, 0, sizeof(int)); data.size += sizeof(int); m_SendBuffer.Enqueue(data); m_SendEvent.Set(); } }
public void Send(SendBuffer ptr) { Net.Write(ptr.buffer, 0, ptr.size); }