Exemple #1
0
        private static Pluto GetPluto(MSGIDType msgId)
        {
            if (msgIdToPluto.ContainsKey(msgId))
            {
                return(msgIdToPluto[msgId]);
            }
            Pluto pluto;

            switch (msgId)
            {
            case MSGIDType.BASEAPP_CLIENT_MOVE_REQ:
                pluto = MovePluto.Create();
                break;

            case MSGIDType.BASEAPP_CLIENT_RPCALL:
            case MSGIDType.CLIENT_RPC_RESP:
                pluto = RpcCallPluto.Create();
                break;

            case MSGIDType.LOGINAPP_LOGIN:
            case MSGIDType.CLIENT_LOGIN_RESP:
                pluto = LoginPluto.Create();
                break;

            case MSGIDType.CLIENT_NOTIFY_ATTACH_BASEAPP:
                pluto = BaseLoginPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_ATTACHED:
                pluto = EntityAttachedPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_NEW_ENTITY:
                pluto = AOINewEntityPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_DEL_ENTITY:
                pluto = AOIDelEntityPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_POS_SYNC:
                pluto = OtherEntityPosSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_POS_PULL:
                pluto = OtherEntityPosPullPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_TELEPORT:
                pluto = OtherEntityPosTeleportPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_CELL_ATTACHED:
                pluto = EntityCellAttachedPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_ENTITIES:
                pluto = AOIEntitiesPluto.Create();
                break;

            case MSGIDType.CLIENT_AVATAR_ATTRI_SYNC:
                pluto = AvatarAttriSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_ATTRI_SYNC:
                pluto = OtherAttriSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_SYNC:
                pluto = EntityPosSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_PULL:
                pluto = EntityPosPullPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_TELEPORT:
                pluto = EntityPosTeleportPluto.Create();
                break;

            case MSGIDType.CLIENT_CHECK_RESP:
                pluto = CheckDefMD5Pluto.Create();
                break;

            case MSGIDType.BASEAPP_CLIENT_REFUSE_RELOGIN:
                pluto = ReConnectRefusePluto.Create();
                break;

            case MSGIDType.NOTIFY_CLIENT_DEFUSE_LOGIN:
                pluto = DefuseLoginPluto.Create();
                break;

            default:
                pluto = NotImplementedPluto.Create();
                break;
            }
            msgIdToPluto[msgId] = pluto;
            return(pluto);
        }
Exemple #2
0
        ///// <summary>
        ///// 将远程调用的方法解码为具体的方法调用。
        ///// </summary>
        ///// <param name="data">远程调用方法的二进制数组</param>
        public static Pluto Decode(Byte[] data)
        {
            Int32 unLen = 0;
            Pluto pluto;
            //string str = BitConverter.ToString(data, 0, data.Length);
            //LoggerHelper.Debug("pluto decode=" + str+"str length="+str.Length+"data length="+data.Length);
            var msgId = (MSGIDType)VUInt16.Instance.Decode(data, ref unLen);

            encryto.Reset();
            int len = data.Length;

            for (int i = unLen; i < len; ++i)
            {
                data[i] = encryto.Decode(data[i]);
            }
            //LoggerHelper.Debug("unLen=" + unLen + "msgid=" + msgId);
            Mogo.Util.LoggerHelper.Debug("msg_id: " + msgId);
            switch (msgId)
            {
            case MSGIDType.CLIENT_RPC_RESP:
                pluto = RpcCallPluto.Create();
                break;

            case MSGIDType.CLIENT_LOGIN_RESP:
                pluto = LoginPluto.Create();
                break;

            case MSGIDType.CLIENT_NOTIFY_ATTACH_BASEAPP:
                pluto = BaseLoginPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_ATTACHED:
                //LoggerHelper.Debug("start entity attached");
                pluto = EntityAttachedPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_NEW_ENTITY:
                pluto = AOINewEntityPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_DEL_ENTITY:
                pluto = AOIDelEntityPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_POS_SYNC:
                pluto = OtherEntityPosSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_POS_PULL:
                pluto = OtherEntityPosPullPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_TELEPORT:
                pluto = OtherEntityPosTeleportPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_CELL_ATTACHED:
                pluto = EntityCellAttachedPluto.Create();
                break;

            case MSGIDType.CLIENT_AOI_ENTITIES:
                pluto = AOIEntitiesPluto.Create();
                break;

            case MSGIDType.CLIENT_AVATAR_ATTRI_SYNC:
                pluto = AvatarAttriSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_OTHER_ENTITY_ATTRI_SYNC:
                pluto = OtherAttriSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_SYNC:
                pluto = EntityPosSyncPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_PULL:
                pluto = EntityPosPullPluto.Create();
                break;

            case MSGIDType.CLIENT_ENTITY_POS_TELEPORT:
                pluto = EntityPosTeleportPluto.Create();
                break;

            case MSGIDType.CLIENT_CHECK_RESP:
                pluto = CheckDefMD5Pluto.Create();
                break;

            case MSGIDType.BASEAPP_CLIENT_REFUSE_RELOGIN:
                pluto = ReConnectRefusePluto.Create();
                break;

            case MSGIDType.NOTIFY_CLIENT_DEFUSE_LOGIN:
                pluto = DefuseLoginPluto.Create();
                break;

            default:
                pluto = NotImplementedPluto.Create();
                break;
            }



            pluto.DoDecode(data, ref unLen);

            return(pluto);
        }