Example #1
0
        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();
        }
Example #2
0
 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()));
 }
Example #3
0
 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.");
 }
Example #4
0
 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);
         }
     }
 }
Example #5
0
 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);
         }
     }
 }