Example #1
0
        private void UpdateFrame()
        {
            if (this.Queue.Count == 0)
            {
                return;
            }
            SessionFrameMessage sessionFrameMessage = this.Queue.Dequeue();

            this.Frame = sessionFrameMessage.FrameMessage.Frame;

            for (int i = 0; i < sessionFrameMessage.FrameMessage.Messages.Count; ++i)
            {
                OneFrameMessage oneFrameMessage = sessionFrameMessage.FrameMessage.Messages[i];

                Session             session             = sessionFrameMessage.Session;
                OpcodeTypeComponent opcodeTypeComponent = session.Network.Entity.GetComponent <OpcodeTypeComponent>();
                Type type = opcodeTypeComponent.GetType(oneFrameMessage.Op);

                IMessage message = (IMessage)session.Network.MessagePacker.DeserializeFrom(type, oneFrameMessage.AMessage);
                Game.Scene.GetComponent <MessageDispatherComponent>().Handle(sessionFrameMessage.Session, new MessageInfo(oneFrameMessage.Op, message));
            }
        }
Example #2
0
        public void Update()
        {
            if (this.Queue.Count == 0)
            {
                return;
            }
            SessionFrameMessage sessionFrameMessage = this.Queue.Dequeue();

            this.Frame = sessionFrameMessage.FrameMessage.Frame;
            for (int i = 0; i < sessionFrameMessage.FrameMessage.Message.Count; ++i)
            {
                OneFrameMessage oneFrameMessage = sessionFrameMessage.FrameMessage.Message[i];

                Session             session             = sessionFrameMessage.Session;
                OpcodeTypeComponent opcodeTypeComponent = session.Network.Entity.GetComponent <OpcodeTypeComponent>();
                ushort opcode   = (ushort)oneFrameMessage.Op;
                object instance = opcodeTypeComponent.GetInstance(opcode);

                byte[]           bytes   = ByteString.Unsafe.GetBuffer(oneFrameMessage.AMessage);
                ETModel.IMessage message = (ETModel.IMessage)session.Network.MessagePacker.DeserializeFrom(instance, bytes, 0, bytes.Length);
                Game.Scene.GetComponent <MessageDispatherComponent>().Handle(sessionFrameMessage.Session, new MessageInfo((ushort)oneFrameMessage.Op, message));
            }
        }