Exemple #1
0
 private void ReceivedLoginResponse(SDKClient.Model.PackageInfo packageInfo)
 {
     if (packageInfo.code == 0)
     {
         //this.CurrentLogin.User.ID = (packageInfo as SDKClient.Model.AuthPackage).data.userId;
         //连接成功
     }
     else
     {
         if (IsActive)
         {
             IsReturnQRLogin = true;
             this.ErrorInfo  = packageInfo.error;
         }
     }
 }
Exemple #2
0
        private void ReceivedAuthResponse(SDKClient.Model.PackageInfo packageInfo)
        {
            //this.IsWaitForLogin = true;
            if (packageInfo.code == 0 && this.CurrentUser != null && _isLogin)
            {
                //this.SelectedLogin.ID = this.SelectedLogin.User.ID = (packageInfo as SDKClient.Model.AuthPackage).data.userId;

                this.CurrentUser.ID = (packageInfo as SDKClient.Model.AuthPackage).data.userId;

                //连接成功
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    //IsLoginSuccess = true;

                    //this.IsEnabledWindow = false;

                    SDKClient.SDKClient.Instance.NewDataRecv -= Instance_NewDataRecv;
                    SDKClient.SDKClient.Instance.ConnState   -= Instance_ConnState;

                    //if (_timer != null)
                    //{
                    //    _timer.Stop();
                    //    _timer.IsEnabled = false;
                    //    _timer = null;
                    //}
                    SDKClient.SDKClient.Instance.GetBadWordEditTime();
                    this.OnLoginSuccess?.Invoke(this.CurrentUser);
                });
            }
            else
            {
                if (IsActive)
                {
                    this.ErrorInfo = packageInfo.error;
                }
                ////连接失败
                //LoginFailed(packageInfo.error);
            }
        }
Exemple #3
0
        private void Instance_NewDataRecv(object sender, SDKClient.Model.PackageInfo e)
        {
            this.ErrorInfo = string.Empty;
            switch (e.apiId)
            {
            case SDKClient.Protocol.ProtocolBase.GetLoginQRCodeCode:
                if (e is GetLoginQRCodePackage qrCodePackage)
                {
                    GetQRimg(qrCodePackage.data.qrcode);
                }
                break;

            case SDKClient.Protocol.ProtocolBase.GetClientIDCode:     //获取Guid
                if (e is GetClientIDPackage clinetID)
                {
                    GetQRimg(clinetID.data.clientId);
                }
                break;

            case SDKClient.Protocol.ProtocolBase.QRScanCode:     // 用户基本信息
                if (e is QRScanPackage qrScan)
                {
                    UserModel user = new UserModel()
                    {
                        ID          = qrScan.data.userId.ToInt(),
                        PhoneNumber = qrScan.data.mobile,
                        Name        = qrScan.data.username,
                        HeadImg     = qrScan.data.photo,
                    };

                    user.HeadImg = IMClient.Helper.ImageHelper.GetAccountFace(user.HeadImg, (s) => App.Current.Dispatcher.Invoke(() => user.HeadImg = s));

                    CurrentUser = user;
                    if (CanLogin(false))
                    {
                        this.IsWaitingLogin = true;
                    }
                    IsReturnQRLogin = true;
                }
                break;

            case SDKClient.Protocol.ProtocolBase.QRConfirmCode:     //手机端确认登录,
                if (CanLogin(true))
                {
                    _isLogin = true;
                    Util.Helpers.Async.Run(async() => await SDKClient.SDKClient.Instance.CreateConn());
                }
                break;

            case SDKClient.Protocol.ProtocolBase.QRCancelCode:     //手机端不登录,取消操作
                //this.IsActive = false;
                this.IsWaitingLogin = false;
                this.CurrentUser    = null;
                IsReturnQRLogin     = false;
                SDKClient.SDKClient.Instance.GetLoginQRCode();
                break;

            case SDKClient.Protocol.ProtocolBase.QRExpiredCode:     //二维码过期处理

                if (e is QRExpiredPackage expired)
                {
                    GetQRimg(expired.data.qrcode);
                    IsReturnQRLogin = false;
                }
                break;

            case SDKClient.Protocol.ProtocolBase.ForceExitCode:     //手机端强制PC端退出
                SDKClient.SDKClient.Instance.SendLogout(SDKClient.SDKProperty.LogoutModel.Logout_kickout);
                App.ReStart();
                break;

            case SDKClient.Protocol.ProtocolBase.authCode:
                ReceivedAuthResponse(e);
                break;

            case SDKClient.Protocol.ProtocolBase.loginCode:
                ReceivedLoginResponse(e);
                break;
            }
        }