Ejemplo n.º 1
0
        public void Run(BK.Session s, Packet packet)
        {
            ushort opcode = packet.Opcode;
            byte   flag   = packet.Flag;

            OpcodeTypeComponent opcodeTypeComponent = Game.OpcodeTypeComponent;
            Type   responseType = opcodeTypeComponent.GetType(opcode);
            object message      = this.session.Network.MessagePacker.DeserializeFrom(responseType, packet.Stream);

            if ((flag & 0x01) > 0)
            {
                IResponse response = message as IResponse;
                if (response == null)
                {
                    throw new Exception($"flag is response, but hotfix message is not! {opcode}");
                }

                Action <IResponse> action;
                if (!this.requestCallback.TryGetValue(response.RpcId, out action))
                {
                    return;
                }
                this.requestCallback.Remove(response.RpcId);

                action(response);
                return;
            }

            Game.MessageDispatherComponent.Handle(session, new MessageInfo(opcode, message));
        }
Ejemplo n.º 2
0
        public void Handle(BK.Session session, object msg)
        {
            Message message = msg as Message;

            if (message == null)
            {
                Log.Error($"消息类型转换错误: {msg.GetType().Name} to {typeof(Message).Name}");
            }
            this.Run(session, message);
        }
Ejemplo n.º 3
0
        public void Handle(BK.Session session, MessageInfo messageInfo)
        {
            List <IMHandler> actions;

            if (!this.handlers.TryGetValue(messageInfo.Opcode, out actions))
            {
                Log.Error($"消息 {messageInfo.Message.GetType().FullName} 没有处理");
                return;
            }

            foreach (IMHandler ev in actions)
            {
                try
                {
                    ev.Handle(session, messageInfo.Message);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
Ejemplo n.º 4
0
 protected override void Run(BK.Session session, G2C_TestHotfixMessage message)
 {
     Log.Debug(message.Info);
 }
Ejemplo n.º 5
0
 protected abstract void Run(BK.Session session, Message message);
Ejemplo n.º 6
0
 protected override void Run(BK.Session session, Actor_Test message)
 {
     Log.Debug(message.Info);
 }