Exemple #1
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            var info = new AttachedInfo();

            info.id    = (uint)VUInt32.Instance.Decode(data, ref unLen); //entity unique id
            info.props = new List <EntityPropertyValue>();
            if (GetEntity != null)
            {
                var entity = GetEntity(info.id);
                if (entity != null)
                {
                    while (unLen < data.Length)
                    {
//还有数据就解析
                        var index = VUInt16.Instance.Decode(data, ref unLen);
                        EntityDefProperties prop;
                        var flag = entity.Properties.TryGetValue((ushort)index, out prop);
                        if (flag)
                        {
                            info.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen)));
                        }
                    }
                }
            }
            Arguments = new object[1] {
                info
            };
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_OTHER_ENTITY_ATTRI_SYNC, Arguments);
            }
        }
Exemple #2
0
        /// <summary>
        ///     将远程调用的方法解码为EntityAttachedPluto调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            //ushort klen = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            var info = new BaseAttachedInfo();

            info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen); //entity type id
            info.id     = (uint)VUInt32.Instance.Decode(data, ref unLen);   //entity unique id
            info.dbid   = (ulong)VUInt64.Instance.Decode(data, ref unLen);  //dbid
            var entity = DefParser.Instance.GetEntityByID(info.typeId);

            if (entity != null)
            {
                info.entity = entity;
                info.props  = new List <EntityPropertyValue>();
                while (unLen < data.Length)
                {
//还有数据就解析
                    var index = (ushort)VUInt16.Instance.Decode(data, ref unLen);
                    EntityDefProperties prop;
                    var flag = entity.Properties.TryGetValue(index, out prop);
                    if (flag)
                    {
                        info.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen)));
                    }
                }
            }
            Arguments = new object[1] {
                info
            };
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_ENTITY_ATTACHED, Arguments);
            }
        }
Exemple #3
0
 protected override void DoDecode(byte[] data, ref int unLen)
 {
     Arguments    = new Object[1];
     Arguments[0] = VUInt32.Instance.Decode(data, ref unLen);
     if (RPCMsgLogManager.IsRecord)
     {
         RPCMsgLogManager.Receive(MSGIDType.CLIENT_AOI_DEL_ENTITY, Arguments);
     }
 }
Exemple #4
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            FuncName = MSGIDType.CLIENT_CHECK_RESP.ToString();

            Arguments    = new Object[1];
            Arguments[0] = VUInt8.Instance.Decode(data, ref unLen);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_CHECK_RESP, Arguments);
            }
        }
Exemple #5
0
        /// <summary>
        ///     将远程调用的方法解码为BaseLogin调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            FuncName = MSGIDType.CLIENT_NOTIFY_ATTACH_BASEAPP.ToString();

            Arguments    = new Object[3];
            Arguments[0] = VString.Instance.Decode(data, ref unLen);
            Arguments[1] = VUInt16.Instance.Decode(data, ref unLen);
            Arguments[2] = VString.Instance.Decode(data, ref unLen);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_NOTIFY_ATTACH_BASEAPP, Arguments);
            }
        }
Exemple #6
0
        public Byte[] Encode(string key)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.BASEAPP_CLIENT_RELOGIN));
            Push(VString.Instance.Encode(key));

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Send(MSGIDType.BASEAPP_CLIENT_RELOGIN, key);
            }
            return(result);
        }
Exemple #7
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            /*[UINT16][UINT16][UINT32][UINT8][INT16][INT16] [UINT16]  [UINT16][UINT32][UINT8][INT16][INT16] [....]  [UINT16]  [UINT16][UINT32][UINT8][INT16][INT16] [....] ...
             * 总长度   etype   eid     face    x      y    单个aoi长度 etype    eid     face   x       y     属性    单个aoi长度 etype    eid     face   x       y     属性
             */
            var list = new List <CellAttachedInfo>();

            while (unLen < data.Length)
            {
                var entityInfo   = new CellAttachedInfo();
                var entityLength = (ushort)VUInt16.Instance.Decode(data, ref unLen); //单个entity数据总长度
                var endIdx       = unLen + entityLength;                             //结束位置
                entityInfo.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen);
                entityInfo.id     = (uint)VUInt32.Instance.Decode(data, ref unLen);  // eid
                entityInfo.face   = (byte)VUInt8.Instance.Decode(data, ref unLen);   // rotation
                var entityX = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
                var entityY = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
                var entityZ = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
                entityInfo.x = (short)entityX;
                entityInfo.y = (short)entityY;
                entityInfo.z = (short)entityZ;
                var entity = DefParser.Instance.GetEntityByID(entityInfo.typeId);
                if (entity != null)
                {
                    entityInfo.entity = entity;
                    entityInfo.props  = new List <EntityPropertyValue>();
                    while (unLen < endIdx)
                    {
                        //还有数据就解析
                        var index = VUInt16.Instance.Decode(data, ref unLen);
                        EntityDefProperties prop;
                        var flag = entity.Properties.TryGetValue((ushort)index, out prop);
                        if (flag)
                        {
                            entityInfo.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen)));
                        }
                    }
                }
                list.Add(entityInfo);
            }
            Arguments    = new Object[1];
            Arguments[0] = list;
            //LoggerHelper.Debug("list: " + list.Count);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_AOI_ENTITIES, list.PackList());
            }
        }
Exemple #8
0
        public Byte[] Encode(Byte[] bytes)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.LOGINAPP_CHECK));
            var str = Util.Utils.FormatMD5(bytes);

            Push(VString.Instance.Encode(str));

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Send(MSGIDType.LOGINAPP_CHECK, str);
            }
            return(result);
        }
Exemple #9
0
        /// <summary>
        ///     将远程方法调用编码为二进制数组。
        /// </summary>
        /// <param name="passport">登录帐号</param>
        /// <param name="password">登录密码</param>
        /// <param name="loginArgs">登录类型参数</param>
        /// <returns>编码后的二进制数组</returns>
        public Byte[] Encode(String passport, String password, String loginArgs)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.LOGINAPP_LOGIN));
            Push(VString.Instance.Encode(passport));
            Push(VString.Instance.Encode(password));
            Push(VString.Instance.Encode(loginArgs));

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Send(MSGIDType.LOGINAPP_LOGIN, passport, loginArgs);
            }
            return(result);
        }
Exemple #10
0
        /// <summary>
        ///     将远程方法调用编码为二进制数组。
        /// </summary>
        /// <returns>编码后的二进制数组</returns>
        public Byte[] Encode(params string[] args)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.LOGINAPP_LOGIN));
            foreach (var item in args)
            {
                Push(VString.Instance.Encode(item));
            }

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Send(MSGIDType.LOGINAPP_LOGIN, args.PackArray());
            }
            return(result);
        }
Exemple #11
0
        /// <summary>
        ///     将远程方法调用编码为二进制数组。
        /// </summary>
        /// <param name="x1"></param>
        /// <param name="y1"></param>
        /// <param name="x2"></param>
        /// <param name="y2"></param>
        /// <param name="x3"></param>
        /// <param name="y3"></param>
        /// <returns>编码后的二进制数组</returns>
        public Byte[] Encode(byte face, ushort x, ushort y, ushort z)
        {
            Push(VUInt16.Instance.Encode(MSGIDType.BASEAPP_CLIENT_MOVE_REQ));
            Push(VUInt8.Instance.Encode(face));
            Push(VUInt16.Instance.Encode(x));
            Push(VUInt16.Instance.Encode(y));
            Push(VUInt16.Instance.Encode(z));

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Send(MSGIDType.BASEAPP_CLIENT_MOVE_REQ, x, y);
            }
            return(result);
        }
Exemple #12
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);
            var x = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
            var y = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
            var z = (UInt16)VUInt16.Instance.Decode(data, ref unLen);

            info.x = (short)x;
            info.y = (short)y;
            info.z = (short)z;

            Arguments = new object[1] {
                info
            };
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_ENTITY_POS_SYNC, Arguments);
            }
        }
Exemple #13
0
        /// <summary>
        ///     将远程方法调用编码为二进制数组。
        /// </summary>
        /// <param name="args">参数列表</param>
        /// <returns>编码后的二进制数组</returns>
        public Byte[] Encode(params Object[] args)
        {
            var entityDef = CurrentEntity; //DefParser.Instance.GetEntityByName(EntityName);

            if (entityDef == null)
            {
                throw new DefineParseException(String.Format("Encode error: CurrentEntity is null."));
            }

            var method = svrMethod;

            FuncID   = method.FuncID;
            FuncName = method.FuncName;

            if (method.ArgsType.Count != args.Length)
            {
                throw new DefineParseException(
                          String.Format(
                              "Encode error: The number of parameters is not match. func: {0}, require num: {1}, current num: {2}.",
                              FuncID, method.ArgsType.Count, args.Length));
            }
            Push(VUInt16.Instance.Encode(MSGIDType.BASEAPP_CLIENT_RPCALL)); // 指定 pluto 类型为 rpc
            Push(VUInt16.Instance.Encode(FuncID));                          // 指定 调用的 func 标识
            for (var i = 0; i < args.Length; i++)
            {
                Push(method.ArgsType[i].Encode(args[i])); // 增加参数
            }

            var result = new Byte[m_unLen];

            Buffer.BlockCopy(m_szBuff, 0, result, 0, m_unLen);
            EndPluto(result);
            if (RPCMsgLogManager.IsRecord)
            {
                var list = new List <object>(2 + args.Length);
                list.Add(FuncID);
                list.Add(FuncName);
                list.AddRange(args);
                RPCMsgLogManager.Send(MSGIDType.BASEAPP_CLIENT_RPCALL, list.ToArray());
            }
            return(result);
        }
Exemple #14
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            var info = new CellAttachedInfo();
            //info.id = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid
            //info.face = (byte)VUInt8.Instance.Decode(data, ref unLen);// rotation
            //info.x = (short)VInt16.Instance.Decode(data, ref unLen); //x
            //info.y = (short)VInt16.Instance.Decode(data, ref unLen); //y
            var x = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
            var y = (UInt16)VUInt16.Instance.Decode(data, ref unLen);

            info.x = (short)x;
            info.y = (short)y;

            Arguments    = new Object[1];
            Arguments[0] = info;
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_ENTITY_POS_PULL, Arguments);
            }
        }
Exemple #15
0
        /// <summary>
        ///     将远程调用的方法解码为RpcCall调用。
        /// </summary>
        /// <param name="data">远程调用方法的二进制数组</param>
        /// <param name="unLen">数据偏移量</param>
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            FuncID = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            if (CurrentEntity == null)
            {
                throw new DefineParseException(String.Format("Decode error: Current Entity is not set."));
            }
            var method = CurrentEntity.TryGetClientMethod(FuncID);

            if (method == null)
            {
                throw new DefineParseException(
                          String.Format("Decode error: Can not find function '{0}' in entity '{1}'.", FuncID,
                                        CurrentEntity.Name));
            }

            FuncName  = method.FuncName;
            Arguments = new Object[method.ArgsType.Count];
            for (var i = 0; i < method.ArgsType.Count; i++)
            {
                Arguments[i] = method.ArgsType[i].Decode(data, ref unLen);
            }
            if (RPCMsgLogManager.IsRecord)
            {
                var list = new List <object>(2 + Arguments.Length);
                list.Add(FuncID);
                list.Add(FuncName);
                for (var i = 0; i < Arguments.Length; i++)
                {
                    if (method.ArgsType[i].VType == VType.V_BLOB)
                    {
                        list.Add(Arguments[i] != null ? (Arguments[i] as byte[]).PackArray() : null);
                    }
                    else
                    {
                        list.Add(Arguments[i]);
                    }
                }
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_RPC_RESP, list.ToArray());
            }
        }
Exemple #16
0
        protected override void DoDecode(byte[] data, ref int unLen)
        {
            var info = new CellAttachedInfo();

            info.typeId = (ushort)VUInt16.Instance.Decode(data, ref unLen);
            info.id     = (uint)VUInt32.Instance.Decode(data, ref unLen); // eid
            info.face   = (byte)VUInt8.Instance.Decode(data, ref unLen);  // rotation
            var x = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
            var y = (UInt16)VUInt16.Instance.Decode(data, ref unLen);
            var z = (UInt16)VUInt16.Instance.Decode(data, ref unLen);

            info.x = (short)x;
            info.y = (short)y;
            info.z = (short)z;
            var entity = DefParser.Instance.GetEntityByID(info.typeId);

            if (entity != null)
            {
                info.entity = entity;
                info.props  = new List <EntityPropertyValue>();
                while (unLen < data.Length)
                {
                    //还有数据就解析
                    var index = VUInt16.Instance.Decode(data, ref unLen);
                    EntityDefProperties prop;
                    var flag = entity.Properties.TryGetValue((ushort)index, out prop);
                    if (flag)
                    {
                        info.props.Add(new EntityPropertyValue(prop, prop.VType.Decode(data, ref unLen)));
                    }
                }
            }
            Arguments = new object[1] {
                info
            };
            if (RPCMsgLogManager.IsRecord)
            {
                RPCMsgLogManager.Receive(MSGIDType.CLIENT_AOI_NEW_ENTITY, Arguments);
            }
        }