private void UpdateList(int ms = 1000) { int counter = 0; while (true) { this.Invoke(new Action(() => { UpdateListBoxItems(ref LstSessions, ref HistoryMsg.Friend); UpdateListBoxItems(ref LstGroupMsg, ref HistoryMsg.Group); })); if (counter == 0) { var contact = session.GetFriendListAsync().Result; this.Invoke(new Action(() => { UpdateListBoxItems(ref LstContacts, contact); })); var group = session.GetGroupListAsync().Result; this.Invoke(new Action(() => { UpdateListBoxItems(ref LstGroups, group); })); } if (counter == 5 * 60) { counter = 0; } Thread.Sleep(ms); ++counter; } // ReSharper disable once FunctionNeverReturns }
public QClient(string addr, int port, string passwd, long account) { MiraiHttpSessionOptions options = new MiraiHttpSessionOptions(addr, port, passwd); session = new MiraiHttpSession(); handler = new EventHandler(this); conversations = new List <Conversation>(); session.ConnectAsync(options, account).Wait(); friends = session.GetFriendListAsync().Result.ToList(); groups = session.GetGroupListAsync().Result.ToList(); session.AddPlugin(handler); }
public static Task <IGroupInfo[]> GetGroupListAsync() => session.GetGroupListAsync();