示例#1
0
        public NetworkPipelineProcessor(params INetworkParameter[] param)
        {
            NetworkPipelineParams config = default(NetworkPipelineParams);

            for (int i = 0; i < param.Length; ++i)
            {
                if (param[i] is NetworkPipelineParams)
                {
                    config = (NetworkPipelineParams)param[i];
                }
            }
            m_StageCollection = new TNetworkPipelineStageCollection();
            m_StageCollection.Initialize(param);
            m_StageList       = new NativeList <int>(16, Allocator.Persistent);
            m_Pipelines       = new NativeList <PipelineImpl>(16, Allocator.Persistent);
            m_ReceiveBuffer   = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            m_SendBuffer      = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            m_SharedBuffer    = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            sizePerConnection = new NativeArray <int>(3, Allocator.Persistent);
            // Store an int for the spinlock first in each connections send buffer
            sizePerConnection[SendSizeOffset] = 4;
            m_ReceiveStageNeedsUpdate         = new NativeList <UpdatePipeline>(128, Allocator.Persistent);
            m_SendStageNeedsUpdate            = new NativeList <UpdatePipeline>(128, Allocator.Persistent);
            m_SendStageNeedsUpdateRead        = new NativeQueue <UpdatePipeline>(Allocator.Persistent);
            m_timestamp = new NativeArray <long>(1, Allocator.Persistent);
        }
示例#2
0
        public unsafe NetworkPipelineProcessor(params INetworkParameter[] param)
        {
            NetworkPipelineParams config = default(NetworkPipelineParams);

            for (int i = 0; i < param.Length; ++i)
            {
                if (param[i] is NetworkPipelineParams)
                {
                    config = (NetworkPipelineParams)param[i];
                }
            }

            int staticBufferSize = 0;

            for (int i = 0; i < NetworkPipelineStageCollection.m_stages.Count; ++i)
            {
                staticBufferSize += NetworkPipelineStageCollection.m_stages[i].StaticSize;
                staticBufferSize  = (staticBufferSize + 15) & (~15);
            }
            m_StaticInstanceBuffer = new NativeArray <byte>(staticBufferSize, Allocator.Persistent);
            m_StageCollection      = new NativeArray <NetworkPipelineStage>(NetworkPipelineStageCollection.m_stages.Count, Allocator.Persistent);
            staticBufferSize       = 0;
            for (int i = 0; i < NetworkPipelineStageCollection.m_stages.Count; ++i)
            {
                var stageStruct = NetworkPipelineStageCollection.m_stages[i].StaticInitialize((byte *)m_StaticInstanceBuffer.GetUnsafePtr() + staticBufferSize, NetworkPipelineStageCollection.m_stages[i].StaticSize, param);
                stageStruct.StaticStateStart   = staticBufferSize;
                stageStruct.StaticStateCapcity = NetworkPipelineStageCollection.m_stages[i].StaticSize;
                m_StageCollection[i]           = stageStruct;
                staticBufferSize += NetworkPipelineStageCollection.m_stages[i].StaticSize;
                staticBufferSize  = (staticBufferSize + 15) & (~15);
            }

            m_StageList       = new NativeList <int>(16, Allocator.Persistent);
            m_Pipelines       = new NativeList <PipelineImpl>(16, Allocator.Persistent);
            m_ReceiveBuffer   = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            m_SendBuffer      = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            m_SharedBuffer    = new NativeList <byte>(config.initialCapacity, Allocator.Persistent);
            sizePerConnection = new NativeArray <int>(3, Allocator.Persistent);
            // Store an int for the spinlock first in each connections send buffer, round up to alignment of 8
            sizePerConnection[SendSizeOffset] = Alignment;
            m_ReceiveStageNeedsUpdate         = new NativeList <UpdatePipeline>(128, Allocator.Persistent);
            m_SendStageNeedsUpdate            = new NativeList <UpdatePipeline>(128, Allocator.Persistent);
            m_SendStageNeedsUpdateRead        = new NativeQueue <UpdatePipeline>(Allocator.Persistent);
            m_timestamp = new NativeArray <long>(1, Allocator.Persistent);
        }