예제 #1
0
        public void Handle(ASession session, IMessage msg)
        {
            Message message = msg as Message;

            if (message == null)
            {
                UnityEngine.Debug.LogError($"消息类型转换错误: {msg.GetType().Name} to {typeof(Message).Name}");
                return;
            }
            if (session.Id == 0)
            {
                UnityEngine.Debug.LogError($"session disconnect {msg}");
                return;
            }
            this.Run(session, message);
        }
예제 #2
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...");
        }
예제 #3
0
 protected abstract void Run(ASession session, Message message);