Beispiel #1
0
        private void doWebLogin(String verifyCode, AbstractActionFuture future)
        {
            LoginModule login   = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);
            QQAccount   account = (QQAccount)getContext().getAccount();

            login.webLogin(account.getUsername(), account.getPassword(),
                           account.getUin(), verifyCode, delegate(QQActionEvent evt) {
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    doCheckLoginSig((String)evt.getTarget(), future);
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    QQException ex = (QQException)(evt.getTarget());
                    if (ex.getError() == QQWpfApplication1.action.QQException.QQErrorCode.WRONG_CAPTCHA)
                    {
                        doGetVerify(ex.Message, future);
                    }
                    else
                    {
                        future.notifyActionEvent(
                            QQActionEvent.Type.EVT_ERROR,
                            (QQException)evt.getTarget());
                    }
                }
            });
        }
Beispiel #2
0
        /**
         * <p>doPollMsg.</p>
         */
        public void doPollMsg()
        {
            LoginModule login = (LoginModule)getContext().getModule(AbstractModule.Type.LOGIN);

            login.pollMsg(delegate(QQActionEvent evt) {
                // 回调通知事件函数
                if (evt.getType() == QQActionEvent.Type.EVT_OK)
                {
                    List <QQNotifyEvent> evts = (List <QQNotifyEvent>)evt.getTarget();
                    foreach (QQNotifyEvent e in evts)
                    {
                        getContext().fireNotify(e);
                    }

                    // 准备提交下次poll请求
                    QQSession session = getContext().getSession();
                    if (session.getState() == QQSession.State.ONLINE)
                    {
                        doPollMsg();
                    }
                    else if (session.getState() != QQSession.State.KICKED)
                    {
                        relogin();
                    }
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_ERROR)
                {
                    QQSession session = getContext().getSession();
                    QQAccount account = (QQAccount)getContext().getAccount();
                    session.setState(QQSession.State.OFFLINE);
                    account.setStatus(QQStatus.OFFLINE);
                    //因为自带了错误重试机制,如果出现了错误回调,表明已经超时多次均失败,这里直接返回网络错误的异常
                    QQException ex = (QQException)evt.getTarget();
                    QQWpfApplication1.action.QQException.QQErrorCode code = ex.getError();
                    if (code == QQWpfApplication1.action.QQException.QQErrorCode.INVALID_LOGIN_AUTH)
                    {
                        relogin();
                    }
                    else if (code == QQWpfApplication1.action.QQException.QQErrorCode.IO_ERROR || code == QQWpfApplication1.action.QQException.QQErrorCode.IO_TIMEOUT)
                    {
                        //粗线了IO异常,直接报网络错误
                        getContext().fireNotify(new QQNotifyEvent(QQNotifyEvent.Type.NET_ERROR, ex));
                    }
                    else
                    {
                        relogin();
                        doPollMsg();
                    }
                }
                else if (evt.getType() == QQActionEvent.Type.EVT_RETRY)
                {
                }
            });
        }