Example #1
0
        internal void RegisterControlMessage <T>(MyControlMessageEnum msg, ControlMessageHandler <T> handler, MyMessagePermissions permission) where T : struct
        {
            MyControlMessageCallback <T> callback = new MyControlMessageCallback <T>(handler, MySyncLayer.GetSerializer <T>(), permission);

            m_controlMessageHandlers.Add((int)msg, callback);
            m_controlMessageTypes.Add(typeof(T), msg);
        }
Example #2
0
        protected void RegisterControlMessage <T>(MyControlMessageEnum msg, ControlMessageHandler <T> handler) where T : struct
        {
            MyControlMessageCallback <T> callback = new MyControlMessageCallback <T>(handler, MySyncLayer.GetSerializer <T>());

            m_controlMessageHandlers.Add((int)msg, callback);
            m_controlMessageTypes.Add(typeof(T), msg);
        }
Example #3
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();
        }
Example #4
0
        unsafe void ControlMessageReceived(byte[] data, int dataSize, ulong sender, TimeSpan timestamp)
        {
            ProfilerShort.Begin("Process control message");

            m_controlReceiveStream.Reset(data, dataSize);

            MyControlMessageEnum msgId = (MyControlMessageEnum)m_controlReceiveStream.ReadUShort();

            ITransportCallback handler;

            if (m_controlMessageHandlers.TryGetValue((int)msgId, out handler))
            {
                handler.Receive(m_controlReceiveStream, sender, TimeSpan.Zero);
            }
            ProfilerShort.End();
        }