Пример #1
0
        public void Dispatch(ASession session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
        {
            // 如果是帧同步消息,交给ClientFrameComponent处理
            //FrameMessage frameMessage = message as FrameMessage;
            //if (frameMessage != null)
            //{
            //	Game.Scene.GetComponent<ClientFrameComponent>().Add(session, frameMessage);
            //	return;
            //}

            //// 普通消息或者是Rpc请求消息
            //if (message is AMessage || message is ARequest)
            //{
            //	MessageInfo messageInfo = new MessageInfo(opcode, message);
            //	Game.Scene.GetComponent<MessageDispatherComponent>().Handle(session, messageInfo);
            //	return;
            //}

            //throw new Exception($"message type error: {message.GetType().FullName}");

            UnityEngine.Debug.LogError("Recv Dispatch...");
        }
Пример #2
0
        public void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
        {
            // 如果是帧同步消息,交给ClientFrameComponent处理
            FrameMessage frameMessage = message as FrameMessage;

            if (frameMessage != null)
            {
                Game.Scene.GetComponent <ClientFrameComponent>().Add(session, frameMessage);
                return;
            }

            // 普通消息或者是Rpc请求消息
            if (message is AMessage || message is ARequest)
            {
                MessageInfo messageInfo = new MessageInfo(opcode, message);
                Game.Scene.GetComponent <MessageDispatherComponent>().Handle(session, messageInfo);
                return;
            }

            throw new Exception($"message type error: {message.GetType().FullName}");
        }
Пример #3
0
        public void Send(AMessage message)
        {
            ActorMessageTask task = new ActorMessageTask(this, message);

            this.Add(task);
        }
Пример #4
0
 public ActorMessageTask(ActorProxy proxy, AMessage message)
 {
     this.proxy   = proxy;
     this.message = message;
 }
Пример #5
0
        public void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
        {
            // 普通消息或者是Rpc请求消息
            if (message is AMessage || message is ARequest)
            {
                MessageInfo messageInfo = new MessageInfo(opcode, (AMessage)message);
                if (opcode < 2000)
                {
                    Game.Scene.GetComponent <CrossComponent>().Run(CrossIdType.MessageDeserializeFinish, messageInfo);
                }
                else
                {
                    Game.Scene.GetComponent <MessageDispatherComponent>().Handle(session, messageInfo);
                }
                return;
            }

            throw new Exception($"message type error: {message.GetType().FullName}");
        }
Пример #6
0
        public void Dispatch(Session session, ushort opcode, int offset, byte[] messageBytes, AMessage message)
        {
            // 收到actor消息分发给actor自己去处理
            if (message is ActorRequest actorRequest)
            {
                Entity entity = Game.Scene.GetComponent <ActorManagerComponent>().Get(actorRequest.Id);
                entity.GetComponent <ActorComponent>().Add(new ActorMessageInfo()
                {
                    Session = session, Message = actorRequest
                });
                return;
            }

            if (message is AMessage || message is ARequest)
            {
                Game.Scene.GetComponent <MessageDispatherComponent>().Handle(session, message);
                return;
            }

            throw new Exception($"message type error: {message.GetType().FullName}");
        }