예제 #1
0
        private void HandleMessage(MyPacket p)
        {
            int         bitPosition = p.BitStream.BitPosition;
            MyMessageId id          = (MyMessageId)p.BitStream.ReadByte(8);

            if (id == MyMessageId.FLUSH)
            {
                this.ClearBuffer();
                p.Return();
            }
            else
            {
                p.BitStream.SetBitPositionRead(bitPosition);
                if ((this.IsBuffering && ((id != MyMessageId.JOIN_RESULT) && ((id != MyMessageId.WORLD_DATA) && (id != MyMessageId.WORLD)))) && (id != MyMessageId.PLAYER_DATA))
                {
                    this.m_buffer.Add(p);
                }
                else
                {
                    this.ProfilePacketStatistics(true);
                    MyStatsGraph.Begin("Live data", 0, "HandleMessage", 0xc5, @"E:\Repo1\Sources\Sandbox.Game\Engine\Multiplayer\MyTransportLayer.cs");
                    this.ProcessMessage(p);
                    float?bytesTransfered = null;
                    MyStatsGraph.End(bytesTransfered, 0f, "", "{0} B", null, "HandleMessage", 0xc7, @"E:\Repo1\Sources\Sandbox.Game\Engine\Multiplayer\MyTransportLayer.cs");
                    this.ProfilePacketStatistics(false);
                }
            }
        }
예제 #2
0
        private unsafe void ProcessMessage(MyPacket p)
        {
            HandlerId         id;
            Action <MyPacket> action;

            id.messageId     = (MyMessageId)p.BitStream.ReadByte(8);
            id.receiverIndex = p.BitStream.ReadByte(8);
            if (((ulong)id.messageId) < this.m_thisFrameTraffic.Length)
            {
                int *numPtr1 = (int *)ref this.m_thisFrameTraffic[(int)id.messageId];
                numPtr1[0] += p.BitStream.ByteLength;
            }
            p.Sender = new Endpoint(p.Sender.Id, id.receiverIndex);
            if (!this.m_handlers.TryGetValue(id, out action))
            {
                HandlerId key = new HandlerId {
                    messageId     = id.messageId,
                    receiverIndex = 0xff
                };
                this.m_handlers.TryGetValue(key, out action);
            }
            if (action == null)
            {
                p.Return();
            }
            else
            {
                MyStatsGraph.Begin(MyEnum <MyMessageId> .GetName(id.messageId), 0x7fffffff, "ProcessMessage", 0xe2, @"E:\Repo1\Sources\Sandbox.Game\Engine\Multiplayer\MyTransportLayer.cs");
                action(p);
                MyStatsGraph.End(new float?((float)p.BitStream.ByteLength), 0f, "", "{0} B", null, "ProcessMessage", 0xe4, @"E:\Repo1\Sources\Sandbox.Game\Engine\Multiplayer\MyTransportLayer.cs");
            }
        }
예제 #3
0
        private void OnWorldData(MyPacket packet)
        {
            ServerDataMsg msg = base.ReplicationLayer.OnWorldData(packet);

            this.OnServerData(ref msg);
            packet.Return();
        }
예제 #4
0
        private void OnJoinResult(MyPacket packet)
        {
            JoinResultMsg msg = base.ReplicationLayer.OnJoinResult(packet);

            this.OnUserJoined(ref msg);
            packet.Return();
        }
예제 #5
0
        private void OnClientConnected(MyPacket packet)
        {
            Sync.ClientConnected(packet.Sender.Id.Value);
            ConnectedClientDataMsg msg = base.ReplicationLayer.OnClientConnected(packet);

            this.OnConnectedClient(ref msg);
            packet.Return();
        }
예제 #6
0
        private unsafe void ClientConnected(MyPacket packet)
        {
            Sync.ClientConnected(packet.Sender.Id.Value);
            ConnectedClientDataMsg  msg     = base.ReplicationLayer.OnClientConnected(packet);
            ConnectedClientDataMsg *msgPtr1 = (ConnectedClientDataMsg *)ref msg;

            this.OnConnectedClient(ref (ConnectedClientDataMsg) ref msgPtr1, msg.SteamID);
            packet.Return();
        }
예제 #7
0
        private void ControlMessageReceived(MyPacket p)
        {
            ITransportCallback   callback;
            MyControlMessageEnum enum2 = (MyControlMessageEnum)((byte)p.ByteStream.ReadUShort());

            if (this.m_controlMessageHandlers.TryGetValue((int)enum2, out callback))
            {
                callback.Receive(p.ByteStream, p.Sender.Id.Value);
            }
            p.Return();
        }
예제 #8
0
        private void OnServerStateSync(MyPacket packet)
        {
            byte item = packet.BitStream.ReadByte(8);

            if (!packet.BitStream.ReadBool() && !this.m_acks.Contains(item))
            {
                this.m_acks.Add(item);
            }
            this.m_lastStateSyncPacketId = item;
            packet.Return();
        }
예제 #9
0
        private void OnReplicationCreate(MyPacket packet)
        {
            packet.BitStream.ReadTypeId();
            NetworkId networkId = packet.BitStream.ReadNetworkId();
            MyPacketDataBitStreamBase bitStreamPacketData = MyNetworkWriter.GetBitStreamPacketData();

            bitStreamPacketData.Stream.WriteNetworkId(networkId);
            bitStreamPacketData.Stream.WriteBool(true);
            bitStreamPacketData.Stream.Terminate();
            this.SendReplicableReady(bitStreamPacketData);
            packet.Return();
        }
예제 #10
0
 private void OnServerData(MyPacket packet)
 {
     packet.Return();
 }
예제 #11
0
 private void OnReplicationStreamBegin(MyPacket packet)
 {
     this.OnReplicationCreate(packet);
     packet.Return();
 }
예제 #12
0
 private void OnReplicationIslandDone(MyPacket packet)
 {
     packet.Return();
 }
예제 #13
0
 private void OnReplicationDestroy(MyPacket packet)
 {
     packet.Return();
 }
예제 #14
0
 private void ClientReady(MyPacket packet)
 {
     this.ReplicationLayer.OnClientReady(packet.Sender, packet);
     packet.Return();
 }