Exemplo n.º 1
0
        public bool Speech(string info)
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_SPEECH);//消息ID
            ar.WriteWideStrNoLen(info);
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 2
0
        public bool GetWorldInfo2(int type, string info)
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);


            ar.WriteInt8(GlobalClineMsgId.CLIENT_WORLD_INFO);//消息ID
            ar.WriteInt32(type);
            ar.WriteWideStr(info);
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 发送加密确认消息
        /// </summary>
        /// <returns>发送是否成</returns>
        public bool ClientRetEncode()
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_RET_ENCODE);//消息ID
            ar.WriteUserDataNoLen(fxVerify.mbtInfo);
            ar.WriteInt32(fxVerify.miAddress);
            byte[] btVerify = new byte[16];
            //如果下面没再使用output 就要保证对象不被垃圾回收掉

            fxVerify.GetRetEncodeVerify(ref btVerify);
            ar.WriteUserDataNoLen(btVerify);

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 发送网络延时检测消息
        /// </summary>
        /// <param name="uType"></param>
        /// <returns></returns>
        public bool SendTracert(uint uType = 0)
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_TRACERT);
            //毫秒数
            long clientsteamp = (long)DateTime.Now.Ticks / 10000 & 0xfffffff;

            // 客户端的时间戳,精确到毫秒数
            ar.WriteUInt32((uint)clientsteamp);
            ar.WriteUInt8(uType);
            uSerial = (++uSerial) % 1000;
            ar.WriteUInt32(uSerial);
            ar.WriteUInt16(0);

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 服务器定位消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_location(ref Byte[] data, int len)
        {
            if (len < 16)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            data = arStore.GetData();
            return(arStore.GetLength());
        }
Exemplo n.º 6
0
        public bool CreateRole(ref VarList args)
        {
            try
            {
                if ((args.GetCount() < 2) || (args.GetType(1) != VarType.WideStr))
                {
                    LogSystem.Log("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[16];

                StoreArchive ar = StoreArchive.Load(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.WriteUserDataNoLen(verify);
                ar.WriteUInt16((uint)(args.GetCount() - 2));
                ///ar.WriteInt32();

                if (!AddMsgVarList(ar, args, 2, args.GetCount()))
                {
                    return(false);
                }

                return(m_sender.Send(ar.GetData(), ar.GetLength()));
            }
            catch (System.Exception ex)
            {
                LogSystem.LogError(ex);
                return(false);
            }
        }
Exemplo n.º 7
0
        public bool Select(string object_ident, int func_id)
        {
            if (object_ident == null)
            {
                LogSystem.LogError("GameSender Select object_ident is null");
                return(false);
            }

            if (0 == object_ident.Length)
            {
                LogSystem.LogError("GameSender Select object_ident is empty");
                return(false);
            }


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

            ar.WriteInt8(GlobalClineMsgId.CLIENT_SELECT);//消息ID
            //unsigned char nVerify[16];	// 校验码
            //int nSerial;				// 消息序列号
            //outer_object_t ObjectId;	// 对象标识
            //int nFunctionId;			// 功能号为0表示执行缺省功能
            //byte[] message = TypeConvert.encode(m_buffer,ar.GetLength());
            ObjectID obj = ObjectID.FromString(object_ident);

            byte[] verify = new byte[16];

            fxVerify.GetSelectVerify(func_id, (int)(obj.m_nSerial), mCustomIndex, (int)(obj.m_nIdent), ref verify);
            ar.WriteUserDataNoLen(verify); //检验码

            ar.WriteInt32(mCustomIndex++); //消息序列号
            ar.WriteObject(obj);           //对象标识
            ar.WriteInt32(func_id);

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 服务器所有目标点移动
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_all_dest(ref Byte[] data, int len)
        {
            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            uint nCount = 0;

            arLoad.ReadUInt16(ref nCount);
            arStore.WriteUInt16(nCount);

            if (nCount > 50)
            {
                LogSystem.Log("proc_server_all_dest");
                return(len);
            }
            for (int i = 0; i < nCount; ++i)
            {
                ObjectID objectId = ObjectID.zero;
                arLoad.ReadObject(ref objectId);
                arStore.WriteObject(objectId);

                int x = 0;
                arLoad.ReadInt16(ref x);
                arStore.WriteFloat(x / 100.0f);

                int y = 0;
                arLoad.ReadInt16(ref y);
                arStore.WriteFloat(y / 100.0f);

                int z = 0;
                arLoad.ReadInt16(ref z);
                arStore.WriteFloat(z / 100.0f);

                int orient = 0;
                arLoad.ReadInt16(ref orient);
                arStore.WriteFloat(orient / 100.0f);

                int moveSpeed = 0;
                arLoad.ReadInt16(ref moveSpeed);
                arStore.WriteFloat(moveSpeed / 100.0f);

                int rotateSpeed = 0;
                arLoad.ReadInt16(ref rotateSpeed);
                arStore.WriteFloat(rotateSpeed / 100.0f);

                int jumpSpeed = 0;
                arLoad.ReadInt16(ref jumpSpeed);
                arStore.WriteFloat(jumpSpeed / 100.0f);

                int gravity = 0;
                arLoad.ReadInt16(ref gravity);
                arStore.WriteFloat(gravity / 100.0f);

                int mode = 0;
                arLoad.ReadInt32(ref mode);
                arStore.WriteInt32(mode);
            }


            data = arStore.GetData();
            return(arStore.GetLength());
        }
Exemplo n.º 9
0
        /// <summary>
        /// 服务器移动消息
        /// </summary>
        /// <param name="data"></param>
        /// <param name="len"></param>
        /// <returns></returns>
        private int proc_server_moving(ref Byte[] data, int len)
        {
            if (len < 28)
            {
                return(len);
            }

            LoadArchive arLoad = LoadArchive.Load(data, len);
            // Byte[] buffer = new Byte[1024];
            StoreArchive arStore = StoreArchive.Load(m_pBuffer_SP, 4096);

            uint nMsgType = 0;

            arLoad.ReadUInt8(ref nMsgType);
            arStore.WriteUInt8(nMsgType);

            ObjectID objectId = ObjectID.zero;

            arLoad.ReadObject(ref objectId);
            arStore.WriteObject(objectId);

            int x = 0;

            arLoad.ReadInt16(ref x);
            arStore.WriteFloat(x / 100.0f);

            int y = 0;

            arLoad.ReadInt16(ref y);
            arStore.WriteFloat(y / 100.0f);

            int z = 0;

            arLoad.ReadInt16(ref z);
            arStore.WriteFloat(z / 100.0f);

            int orient = 0;

            arLoad.ReadInt16(ref orient);
            arStore.WriteFloat(orient / 100.0f);

            int moveSpeed = 0;

            arLoad.ReadInt16(ref moveSpeed);
            arStore.WriteFloat(moveSpeed / 100.0f);

            int rotateSpeed = 0;

            arLoad.ReadInt16(ref rotateSpeed);
            arStore.WriteFloat(rotateSpeed / 100.0f);

            int jumpSpeed = 0;

            arLoad.ReadInt16(ref jumpSpeed);
            arStore.WriteFloat(jumpSpeed / 100.0f);

            int gravity = 0;

            arLoad.ReadInt16(ref gravity);
            arStore.WriteFloat(gravity / 100.0f);

            int mode = 0;

            arLoad.ReadInt32(ref mode);
            arStore.WriteInt32(mode);

            data = arStore.GetData();
            return(arStore.GetLength());
        }
Exemplo n.º 10
0
        //发送带验证码的登录消息
        public bool LoginVerify(string account, string password, string verify, string device_uid)
        {
            if (account == null || password == null || verify == null || device_uid == null)
            {
                return(false);
            }

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

            ar.WriteInt8(GlobalClineMsgId.CLIENT_LOGIN); //消息ID
            ar.WriteInt32(OUTER_PROTOCOL_VERSION);       //版本号

            byte[] varify = Encoding.Default.GetBytes(verify);
            ar.WriteUserDataNoLen(varify);//验证码
            byte[] btAccount     = null;
            byte[] btPassword    = null;
            int    iAccountSize  = 0;
            int    iPasswordSize = 0;
            bool   bVerifyok1    = fxVerify.EncodeAccount(account, ref btAccount, ref iAccountSize);
            bool   bVerifyok2    = fxVerify.EncodePassword(password, ref btPassword, ref iPasswordSize);

            if (bVerifyok1 && bVerifyok2)
            {
                ar.WriteUserData(btAccount);  //账号
                ar.WriteUserData(btPassword); //密码
            }
            else
            {
                ar.WriteString(account);
                ar.WriteString(password);
            }
            ar.WriteString(string.Empty); //登录串
            ar.WriteInt32(1);             //登录类型 LOGIN_TYPE_RECONNECT 100
            ar.WriteInt8(0);              ///是否是本地副本
            ar.WriteString(device_uid);

            string strPropMd5 = string.Empty;
            string strRecdMd5 = string.Empty;

            if (mRecver != null)
            {
                strPropMd5 = mRecver.GetPropertyTableMd5();
                strRecdMd5 = mRecver.GetRecordTableMd5();
            }
            if (strPropMd5 != null)
            {
                ar.WriteString(strPropMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }
            if (strRecdMd5 != null)
            {
                ar.WriteString(strRecdMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 11
0
        public bool LoginReconnect(string account, string pswd, string validate_string, string device_uid, bool in_stub = false, string strRoleName = "", string strRoleInfo = "")
        {
            if (account == null || pswd == null || validate_string == null || device_uid == null)
            {
                return(false);
            }

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

            ar.WriteInt8(GlobalClineMsgId.CLIENT_LOGIN);//消息ID
            int iVerson = fxVerify.GetVersion();

            ar.WriteInt32(iVerson);//版本号
            Array.Clear(varifyLoginReconnect, 0, varifyLoginReconnect.Length);
            fxVerify.GetLoginVerify(ref varifyLoginReconnect);
            ar.WriteUserDataNoLen(varifyLoginReconnect);

            byte[] btAccount     = null;
            byte[] btPassword    = null;
            int    iAccountSize  = 0;
            int    iPasswordSize = 0;
            bool   bVerifyok1    = fxVerify.EncodeAccount(account, ref btAccount, ref iAccountSize);
            bool   bVerifyok2    = fxVerify.EncodePassword(pswd, ref btPassword, ref iPasswordSize);

            if (bVerifyok1 && bVerifyok2)
            {
                ar.WriteUserData(btAccount);  //账号
                ar.WriteUserData(btPassword); //密码
            }
            else
            {
                ar.WriteString(account);
                ar.WriteString(pswd);
            }
            ar.WriteString(validate_string); //登录串
            ar.WriteInt32(100);              //登录类型 LOGIN_TYPE_RECONNECT 100
            if (in_stub)
            {
                ar.WriteInt8(1);
            }
            else
            {
                ar.WriteInt8(0);
            }
            ar.WriteString(device_uid);
            string strPropMd5 = string.Empty;
            string strRecdMd5 = string.Empty;

            if (mRecver != null)
            {
                strPropMd5 = mRecver.GetPropertyTableMd5();
                strRecdMd5 = mRecver.GetRecordTableMd5();
            }

            if (strPropMd5 != null)
            {
                ar.WriteString(strPropMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }

            if (strRecdMd5 != null)
            {
                ar.WriteString(strRecdMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }
            //发送角色名称
            if (strRoleName != null)
            {
                ar.WriteWideStr(strRoleName);
            }
            else
            {
                ar.WriteWideStr(string.Empty);
            }
            //发送角色名称
            if (strRoleInfo != null)
            {
                ar.WriteString(strRoleInfo);
            }
            else
            {
                ar.WriteString(string.Empty);
            }
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Exemplo n.º 12
0
        public bool Login(string account, string password, string device_uid)
        {
            StoreArchive ar = StoreArchive.Load(m_buffer, m_buffer.Length);

            ar.WriteInt8(GlobalClineMsgId.CLIENT_LOGIN);//消息ID
            int nVersion = fxVerify.GetVersion();

            ar.WriteInt32(nVersion);//版本号
            Array.Clear(varifyLogin, 0, varifyLogin.Length);
            fxVerify.GetLoginVerify(ref varifyLogin);
            ar.WriteUserDataNoLen(varifyLogin);

            byte[] btAccount     = null;
            byte[] btPassword    = null;
            int    iAccountSize  = 0;
            int    iPasswordSize = 0;
            bool   bVerifyok1    = fxVerify.EncodeAccount(account, ref btAccount, ref iAccountSize);
            bool   bVerifyok2    = fxVerify.EncodePassword(password, ref btPassword, ref iPasswordSize);

            if (bVerifyok1 && bVerifyok2)
            {
                ar.WriteUserData(btAccount);  //账号
                ar.WriteUserData(btPassword); //密码
            }
            else
            {
                ar.WriteString(account);
                ar.WriteString(password);
            }
            ar.WriteString("0"); //登录串
            ar.WriteInt32(1);    //登录类型
            ar.WriteInt8(0);
            ar.WriteString(device_uid);
            string strPropMd5 = string.Empty;
            string strRecdMd5 = string.Empty;

            if (mRecver != null)
            {
                strPropMd5 = mRecver.GetPropertyTableMd5();
                strRecdMd5 = mRecver.GetRecordTableMd5();
            }

            if (strPropMd5 != null)
            {
                ar.WriteString(strPropMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }

            if (strRecdMd5 != null)
            {
                ar.WriteString(strRecdMd5);
            }
            else
            {
                ar.WriteString(string.Empty);
            }

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }