Esempio n. 1
0
        public bool Custom(ref VarList args)
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);


            int iCount = args.GetCount();

            if (!AddMsgVarList(ref ar, ref args, 0, iCount))
            {
                return(false);
            }
            Array.Clear(varifyCustom, 0, varifyCustom.Length);
            fxVerify.GetCustomVerify(mCustomIndex, iCount, ar.GetData(), ar.GetLength(), ref varifyCustom);

            ar = StoreArchive.Load(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_CUSTOM); //消息ID
            ar.WriteUserDataNoLen(varifyCustom);          //校验码

            ar.WriteInt32(mCustomIndex++);
            ar.WriteInt16(iCount);

            if (!AddMsgVarList(ref ar, ref args, 0, iCount))
            {
                LogSystem.Log("add para error");
                return(false);
            }
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Esempio n. 2
0
        //发送请求移动消息
        //public bool RequestMove(int mode, int arg_num, float[] args, string info)
        public bool RequestMove(ref VarList args, ref VarList ret)
        {
            try
            {
                if (args.GetCount() < 1)
                {
                    ret.AddBool(false);
                    return(false);
                }

                int mode    = args.GetInt(0);
                int arg_num = args.GetCount() - 1;

                StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);
                ar.WriteInt8(GlobalClineMsgId.CLIENT_REQUEST_MOVE);//消息ID
                ar.WriteInt8(mode);
                ar.WriteInt16(arg_num);

                for (int i = 0; i < arg_num; i++)
                {
                    float value = args.GetFloat(1 + i);
                    ar.WriteFloat(value);
                }

                return(m_sender.Send(ar.GetData(), ar.GetLength()));
            }
            catch (System.Exception ex)
            {
                LogSystem.LogError(ex);
                return(false);
            }
        }
Esempio n. 3
0
        //发送请求移动消息
        //public bool RequestMove(int mode, int arg_num, float[] args, string info)
        public bool RequestMove(ref VarList args, ref VarList ret)
        {
            try
            {
                if (args.GetCount() < 3)
                {
                    //Log.Trace(" arguments count must be > 3");
                    ret.AddBool(false);
                    return(false);
                }

                int mode    = args.GetInt(0);
                int arg_num = args.GetInt(1);
                if (arg_num > 256)
                {
                    //Log.Trace("more arguments");
                    ret.AddBool(false);
                    return(false);
                }

                if (args.GetCount() < (arg_num + 2))
                {
                    //Log.Trace("too few arguments");
                    ret.AddBool(false);
                    return(false);
                }

                StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);
                ar.WriteInt8(GlobalClineMsgId.CLIENT_REQUEST_MOVE);//消息ID
                ar.WriteInt8(mode);
                ar.WriteInt16(arg_num);

                for (int i = 0; i < arg_num; i++)
                {
                    float value = args.GetFloat(2 + i);
                    ar.WriteFloat(value);
                }

                string info = "";
                if (args.GetCount() > (arg_num + 2))
                {
                    info = args.GetString(arg_num + 2);
                }

                ar.WriteStringNoLen(info);
                return(m_sender.Send(ar.GetData(), ar.GetLength()));
            }
            catch (System.Exception ex)
            {
                Log.TraceExcep(ref ex);
                return(false);
            }
        }
Esempio n. 4
0
        public bool Custom(ref VarList args)
        {
            StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_CUSTOM);//消息ID

            //校验码4个字节,对消息加密获取验证码
            byte[] varify = MsgEncode.Instance.Encode(ref args, 4);
            ar.WriteUserDataNoLen(varify);
            ar.WriteInt16(MsgEncode.Instance.MsgSerial);
            ar.WriteInt16(args.GetCount());
            Log.Trace("Custom");
            if (!AddMsgVarList(ref ar, ref args, 0, args.GetCount()))
            {
                Log.Trace("add para error");
                return(false);
            }
            Log.Trace("Send");

            MsgEncode.Instance.MsgSerial++;

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Esempio n. 5
0
        public bool CreateRole(ref VarList args)
        {
            try
            {
                if ((args.GetCount() < 2) || (args.GetType(1) != VarType.WideStr))
                {
                    //Log.Trace("arguments error");
                    return(false);
                }

                string roleName = args.GetWideStr(1);
                //role name
                //byte[] name = new byte[ServerInfo.ROLENAME_MAX_LENGTH * 2 + 1];
                //Array.Copy(System.Text.Encoding.Default.GetBytes(roleName), name, roleName.Length);

                //verify
                byte[] verify = new byte[4];

                //校验码4个字节,对消息加密获取验证码
                byte[] varify = MsgEncode.Instance.Encode(ref args, 4);

                StoreArchive ar = new StoreArchive(m_buffer, m_buffer.Length);
                ar.WriteInt8(GlobalClineMsgId.CLIENT_CREATE_ROLE);
                ar.WriteInt32(args.GetInt(0));
                ar.WriteUnicodeLen(roleName, (ServerInfo.ROLENAME_MAX_LENGTH + 1) * 2);
                ar.WriteInt16(1);
                ar.WriteInt8(2);
                ar.WriteInt32(args.GetInt(2));
                //ar.WriteUserDataNoLen(verify);
                ar.WriteUserDataNoLen(varify);
                ar.WriteInt8(0);
                return(m_sender.Send(ar.GetData(), ar.GetLength()));
            }
            catch (System.Exception ex)
            {
                Log.TraceExcep(ref ex);
                return(false);
            }
        }