protected override async Task DoReceive() { if (_listId == null) { // get description var list = (await ReceiveListDescription(_auth, _listInfo)); await ListProxy.SetListDescription(list); _listId = list.Id; } // if list data is not found, abort receiving timeline. if (_listId == null) { return; } var id = _listId.Value; var users = (await ReceiveListMembers(_auth, id)).OrderBy(l => l).ToArray(); var oldUsers = (await ListProxy.GetListMembers(id)).OrderBy(l => l).ToArray(); if (users.SequenceEqual(oldUsers)) { // not changed return; } // commit changes await ListProxy.SetListMembers(id, users); ListMemberChanged.SafeInvoke(); }
private async void UsersChanged(IEnumerable <long> userIds) { if (!_members.SyncSet(userIds)) { return; } if (_receiver.ListId != null) { await ListProxy.SetListMembers(_receiver.ListId.Value, _members); } ListMemberChanged?.Invoke(this, Tuple.Create(_listParam, _members.AsEnumerable())); }
public static void Initialize() { BehaviorLogger.Log("RM", "initializing..."); _userReceiveManager = new UserReceiveManager(); _searchReceiveManager = new SearchReceiveManager(); _listReceiveManager = new ListReceiveManager(); _listMemberReceiveManager = new ListMemberReceiveManager(); _listMemberReceiveManager.ListMemberChanged += li => ListMemberChanged.SafeInvoke(li); _streamTrackReceiveManager = new StreamTrackReceiveManager(_userReceiveManager); _userReceiveManager.ConnectionStateChanged += arg => UserStreamsConnectionStateChanged.SafeInvoke(arg); BehaviorLogger.Log("RM", "init."); }
public void StartReceive(TwitterAccount account, ListInfo info) { lock (this._listReceiverLocker) { if (this._listReceiverReferenceCount.ContainsKey(info)) { this._listReceiverReferenceCount[info]++; } else { var lmr = new ListMemberReceiver(account, info); lmr.ListMemberChanged += () => ListMemberChanged.SafeInvoke(info); this._listReceiverReferenceCount.Add(info, 1); this._receiverDictionary.Add(info, lmr); } } }
public void StartReceive(TwitterAccount account, ListInfo info) { lock (_listReceiverLocker) { if (_listReceiverReferenceCount.ContainsKey(info)) { _listReceiverReferenceCount[info]++; } else { _listReceiverReferenceCount.Add(info, 1); var listener = new ListMemberListener(account.CreateAccessor(), info); _receiverDictionary.Add(info, listener); listener.ListMemberChanged += (o, e) => ListMemberChanged?.Invoke(e); } } }