Пример #1
0
        /// <summary>
        /// 断线重连接
        /// </summary>
        /// <param name="account">账号</param>
        /// <param name="pswd">密码</param>
        /// <param name="validate_string">计费串</param>
        /// <param name="device_uid">设备号</param>
        /// <param name="in_stub">是否是本地副本(false)</param>
        /// <returns></returns>
        public bool LoginReconnect(string account, string pswd, string validate_string, string device_uid, bool in_stub = false)
        {
            if (account == null || pswd == null || validate_string == null || device_uid == null)
            {
                return(false);
            }

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

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

            byte[] varify = new byte[4];
            ar.WriteUserDataNoLen(varify);                              //验证码
            ar.WriteUserData(MsgEncode.Instance.EncodeString(account)); //账号
            ar.WriteUserData(MsgEncode.Instance.EncodeString(pswd));    //密码
            ar.WriteString(validate_string);                            //登录串
            ar.WriteInt32(100);                                         //登录类型 LOGIN_TYPE_RECONNECT 100
            ar.WriteString(device_uid);

            string strPropMd5 = null;
            string strRecdMd5 = null;

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

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

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

            if (in_stub)
            {
                ar.WriteInt8(1);
            }
            else
            {
                ar.WriteInt8(0);
            }

            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }
Пример #2
0
        public bool LoginByString(string account, string login_string, 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(varifyByString, 0, varifyByString.Length);
            fxVerify.GetLoginVerify(ref varifyByString);
            ar.WriteUserDataNoLen(varifyByString);


            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("", ref btPassword, ref iPasswordSize);

            if (bVerifyok1 && bVerifyok2)

            {
                ar.WriteUserData(btAccount);  //账号
                ar.WriteUserData(btPassword); //密码
            }
            else
            {
                ar.WriteString(account);
                ar.WriteString("");
            }

            ar.WriteString(login_string); //登录串
            ar.WriteInt32(2);             //登录类型
            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);
            }
            ar.WriteInt8(0);
            return(m_sender.Send(ar.GetData(), ar.GetLength()));
        }