protected AbstractActionFuture(QQActionListener proxyListener) { _isCanceled = false; _hasEvent = true; EventQueue = new BlockingCollection <QQActionEvent>(); ProxyListener = proxyListener; Listener = (sender, args) => { ProxyListener?.Invoke(this, args); EventQueue.Add(args); }; Cts = new CancellationTokenSource(); }
public IQQActionFuture Relogin(QQStatus status, QQActionListener listener) { Context.Account.Status = status; Context.Session.State = QQSessionState.Logining; var login = Context.GetModule <LoginModule>(QQModuleType.LOGIN); var future = login.ChannelLogin(status, (sender, Event) => { if (Event.Type == QQActionEventType.EvtError) { Context.Logger.LogInformation("iqq client ReloginChannel fail!!! use Login."); Login(listener); } else { listener?.Invoke(this, Event); } }); return(future); }
/// <summary> /// 退出登录 /// </summary> /// <param name="listener"></param> /// <returns></returns> public IQQActionFuture Logout(QQActionListener listener) { if (Session.State == QQSessionState.Offline) { // Context.Logger.LogWarning($"{Account.Username}: client is aready offline !!!"); throw new Exception("client is aready offline !!!"); } var procModule = GetModule <ProcModule>(QQModuleType.PROC); return(procModule.DoLogout((sender, Event) => { // 无论退出登录失败还是成功,都需要释放资源 if (Event.Type == QQActionEventType.EvtOK || Event.Type == QQActionEventType.EvtError) { Session.State = QQSessionState.Offline; Destroy(); } listener?.Invoke(sender, Event); })); }