Esempio n. 1
0
    public IEnumerator 구조체에서_바이트변환_다시_구조체로변환_테스트()
    {
        SPacketTest_Struct pPacket1 = new SPacketTest_Struct(1, "테스트Test123!@#");
        SPacketTest_Struct pPacket2 = new SPacketTest_Struct();

        Assert.AreNotEqual(pPacket1, pPacket2);

        byte[] arrData = SCByteHelper.ConvertByteArray(pPacket1);
        SCByteHelper.ConvertPacket(arrData, out pPacket2);

        Assert.AreEqual(pPacket1, pPacket2);

        yield return(null);
    }
Esempio n. 2
0
    private byte[] CombineBuffer_Header_And_Packet(INetworkPacket pPacket, byte[] arrByte)
    {
        bool          bIsGenerate;
        Packet_Header pPacketHeader;

        OnGeneratePacketHeader(pPacket, out bIsGenerate, out pPacketHeader);

        _pBufferSend.Clear();
        if (bIsGenerate)
        {
            pPacketHeader.INetworkPacketHeader_Set_Header(arrByte.Length, pPacket.INetworkPacket_Get_PacketID());
            _pBufferSend.Enqueue(SCByteHelper.ConvertByteArray(pPacketHeader));
        }
        _pBufferSend.Enqueue(SCByteHelper.ConvertByteArray(pPacket));

        return(_pBufferSend.Dequeue_OrNull(_pBufferSend.Count));
    }
Esempio n. 3
0
    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(SCByteHelper.SizeOf <Packet>(), pPacket.INetworkPacket_Get_PacketID());
            _pBufferSend.Enqueue(SCByteHelper.ConvertByteArray(pPacketHeader));
        }
        _pBufferSend.Enqueue(SCByteHelper.ConvertByteArray(pPacket));

        return(_pBufferSend.Dequeue_OrNull(_pBufferSend.Count));
    }
Esempio n. 4
0
    public void 링버퍼_인큐_디큐_테스트()
    {
        SPacketTest_Struct pPacketTest  = new SPacketTest_Struct(1, "인큐_디큐_테스트");
        SPacketTest_Struct pPacketTest2 = new SPacketTest_Struct(2, "더미데이터");

        byte[] arrPacketData = SCByteHelper.ConvertByteArray(pPacketTest);
        int    iDataSize     = arrPacketData.Length;

        var pBuffer = new CircularBuffer <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);
    }
Esempio n. 5
0
 private byte[] CombineBuffer_Header_And_Packet <Packet>(Packet pPacket) where Packet : INetworkPacket
 {
     return(CombineBuffer_Header_And_Packet(pPacket, SCByteHelper.ConvertByteArray(pPacket)));
 }