private byte[] CombineBuffer_Header_And_Packet <Packet>(Packet pPacket, Packet_Header pPacketHeader) where Packet : INetworkPacket { bool bIsGenerate = pPacketHeader != null; if (bIsGenerate == false) { OnGeneratePacketHeader(pPacket, out bIsGenerate, out pPacketHeader); } _pBufferSend.Clear(); if (bIsGenerate) { pPacketHeader.INetworkPacketHeader_Set_Header(ByteExtension.SizeOf <Packet>(), pPacket.INetworkPacket_Get_PacketID()); _pBufferSend.Enqueue(ByteExtension.ConvertByteArray(pPacketHeader)); } _pBufferSend.Enqueue(ByteExtension.ConvertByteArray(pPacket)); return(_pBufferSend.Dequeue_OrNull(_pBufferSend.Count)); }
public void RingBuffer_Enqueue_Dequeue_Test() { SPacketTest_Struct pPacketTest = new SPacketTest_Struct(1, "인큐_디큐_테스트"); SPacketTest_Struct pPacketTest2 = new SPacketTest_Struct(2, "더미데이터"); byte[] arrPacketData = ByteExtension.ConvertByteArray(pPacketTest); int iDataSize = arrPacketData.Length; var pBuffer = new CCircularBuffer <byte>(10240); pBuffer.Enqueue(arrPacketData); Assert.AreNotEqual(pPacketTest.iValue, pPacketTest2.iValue); Assert.AreNotEqual(pPacketTest.strValue, pPacketTest2.strValue); byte[] arrPacketData2 = pBuffer.Dequeue_OrNull(iDataSize); arrPacketData2.Convert_ToStruct(out pPacketTest2); Assert.AreEqual(pPacketTest.iValue, pPacketTest2.iValue); Assert.AreEqual(pPacketTest.strValue, pPacketTest2.strValue); }