Exemplo n.º 1
0
        private void onEventHandlerCheckLoginQrcode(EventWatcher watcher, BaseEventArgs evtArgs)
        {
            if (evtArgs != null)
            {
                if (evtArgs.mEventID == EventConst.ON_LOGIN_GETQRCODE)
                {
                    GetLoginQrcode qrcode = evtArgs.mObject as GetLoginQrcode;
                    if (qrcode.ImgBuf != null)
                    {
                        pB_ShowQrcode.BeginInvoke(new Action(() => pB_ShowQrcode.Image = Image.FromStream(new MemoryStream(qrcode.ImgBuf))));

                        new NetSceneCheckLoginQRCode().doScene(qrcode.Uuid, qrcode.NotifyKey);
                        qrcode.ImgBuf = null;
                    }
                }

                if (evtArgs.mEventID == EventConst.ON_LOGIN_CHECKQRCODE)
                {
                    CheckQrcode qrcode = evtArgs.mObject as CheckQrcode;

                    // Log.d("event", "event thread id " + Thread.CurrentThread.ManagedThreadId.ToString());
                    switch (qrcode.Status)
                    {
                    case 0:
                        lab_ShowMsg.BeginInvoke(new Action(() => lab_ShowMsg.Text = "未扫描 剩余时间" + qrcode.ExpiredTime.ToString() + "S"));
                        break;

                    case 1:
                        lab_ShowMsg.BeginInvoke(new Action(() => lab_ShowMsg.Text = "已扫描 未确认  剩余时间" + qrcode.ExpiredTime.ToString() + "S"));


                        using (WebClient _client = new WebClient())
                        {
                            pB_ShowQrcode.Image = Image.FromStream(new MemoryStream(_client.DownloadData(qrcode.HeadImgUrl)));
                        }

                        break;

                    case 2:
                        lab_ShowMsg.BeginInvoke(new Action(() => lab_ShowMsg.Text = "已确认 " + qrcode.Nickname));

                        //ServiceCenter.sceneAuth.QrcodeLogin(qrcode.Username, qrcode.Password);


                        EventCenter.removeEventWatcher(EventConst.ON_LOGIN_GETQRCODE, this.m_WatcherCheckLoginQrcode);
                        EventCenter.removeEventWatcher(EventConst.ON_LOGIN_CHECKQRCODE, this.m_WatcherCheckLoginQrcode);

                        new NetSceneNewAuth().doScene(qrcode.Username, qrcode.Password);

                        if (Directory.Exists(Directory.GetCurrentDirectory() + "\\User\\" + qrcode.Username + "\\") == false)    //如果不存在就创建file文件夹
                        {
                            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\User\\" + qrcode.Username);
                            Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\User\\" + qrcode.Username + "\\" + ConstantsProtocol.ChatRoomPath);
                        }
                        break;

                    case 4:
                        lab_ShowMsg.BeginInvoke(new Action(() => lab_ShowMsg.Text = "已取消扫描"));
                        break;

                    default:
                        lab_ShowMsg.BeginInvoke(new Action(() => lab_ShowMsg.Text = "debug Status" + qrcode.Status.ToString() + "S"));
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void on_AuthChange_EventHandler(EventWatcher watcher, BaseEventArgs evtArgs)
        {
            if (evtArgs != null)
            {
                if ((EventConst.ON_NETSCENE_AUTOAUTH_ERR == evtArgs.mEventID) || (EventConst.ON_NETSCENE_AUTH_ERR == evtArgs.mEventID))
                {
                    //InputVCodeControl.DismissInputVcodeBox();
                    int mObject = (int)evtArgs.mObject;
                    switch (mObject)
                    {
                    case -100:
                        Log.i(base.GetType().Name, string.Concat(new object[] { "kickout  errorId:", mObject, ",kickMsg = ", AuthPack.mKickMessage }));
                        //MMMessageBox.Show(AuthPack.mKickMessage, true, "确定").ReturnEvent = new DlgReturnEvent(this.AuthErroMsgBoxHandler);
                        return;

                    case -999999:
                        //App.ExitProgram();
                        return;

                    case -205:
                        // if (!PageManager.getInstance().ExsitPage<NewDeviceVerifyPage>())
                        // {
                        //     AccountMgr.SetLoginStatus(false);
                        //     LoginMainView.sStrUserInputUserName = AccountMgr.strUsrName;
                        //     NewDeviceVerifyPage.GotoThisPage(AccountMgr.strBindMobile, new MMUIEvent(this.verifySafeDeviceCb), false, true);
                        //     return;
                        // }
                        return;
                    }
                    //MMMessageBox.Show(strings.MainPage_MsgReLogin, true, "确定").ReturnEvent = new DlgReturnEvent(this.AuthErroMsgBoxHandler);
                }
                else if ((EventConst.ON_NETSCENE_AUTOAUTH_SUCCESS == evtArgs.mEventID) || (EventConst.ON_NETSCENE_AUTH_SUCCESS == evtArgs.mEventID))
                {
                    NetSceneNewSync.isEnable = true;
                    // EventCenter.postEvent(EventConst.ON_APP_ACTIVE, null, null);
                    ServiceCenter.sceneNewSync.doScene(7, syncScene.MM_NEWSYNC_SCENE_OTHER);

                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_ERR, this.m_WatcherLoginErr);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_SUCCESS, this.m_WatcherLoginSuccess);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_NEEDREG, this.m_WatcherLoginNeedReg);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_NEEDVERIFY, this.m_WatcherLoginNeedVCode);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_SUCCESS, this.m_WatcherLoginByPhone);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILEREG_SETPHONE_ERR, this.m_WatcherLoginByPhone);

                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTOAUTH_ERR, this.mAuthChangeWatcher);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_NEEDVERIFY, this.mAuthChangeWatcher);
                    //EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTOAUTH_SUCCESS, this.mAuthChangeWatcher);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_SUCCESS, this.mAuthChangeWatcher);
                    EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_AUTH_ERR, this.mAuthChangeWatcher);



                    //InputVCodeControl.DismissInputVcodeBox();
                }
                else if ((EventConst.ON_NETSCENE_AUTH_NEEDVERIFY == evtArgs.mEventID) && (evtArgs != null))
                {
                    // if (InputVCodeControl.IsShown())
                    // {
                    //InputVCodeControl.SetInputVCodeBoxWrongStage(evtArgs);
                    VerifyCodeArgs mObject = evtArgs.mObject as VerifyCodeArgs;
                    using (FileStream fs = new FileStream(System.IO.Directory.GetCurrentDirectory() + "\\Cache\\" + mObject.mImageSid + ".png", FileMode.Create))
                    {
                        fs.Write(mObject.mImageBuf, 0, mObject.mImageBuf.Length);
                        fs.Close();
                    }
                    // }
                    // else
                    // {
                    //     InputVCodeControl.Show(true, evtArgs, null, null, null, null);
                    // }
                    return;
                }
            }
        }