Example #1
0
 internal static async void Enqueue([NotNull] StatusNotification status)
 {
     if (status == null)
     {
         throw new ArgumentNullException("status");
     }
     _queue.Enqueue(await StatusModelNotification.FromStatusNotification(status, true));
     _signal.Set();
 }
Example #2
0
 internal static async void Enqueue([CanBeNull] StatusNotification status)
 {
     if (status == null)
     {
         throw new ArgumentNullException(nameof(status));
     }
     _queue.Enqueue(await StatusModelNotification.FromStatusNotification(status, true).ConfigureAwait(false));
     _signal.Set();
 }
        public static async Task <StatusModelNotification> FromStatusNotification(StatusNotification notification,
                                                                                  bool isNew)
        {
            var model = notification.Status == null
                ? null
                : await StatusModel.Get(notification.Status).ConfigureAwait(false);

            return(new StatusModelNotification(model, notification.IsAdded, isNew, notification.StatusId));
        }
Example #4
0
 private static async void PumpQueuedStatuses()
 {
     StatusNotification n;
     while (true)
     {
         _signal.Reset();
         while (_queue.TryDequeue(out n) && !_isHaltRequested)
         {
             if (n.IsAdded)
             {
                 // check status duplication
                 if (await StatusProxy.IsStatusExistsAsync(n.Status.Id)) continue;
                 // store status
                 await StatusProxy.StoreStatusAsync(n.Status);
             }
             else
             {
                 var removal = await StatusProxy.GetStatusAsync(n.StatusId);
                 var rtt = StatusProxy.GetRetweetedStatusIds(n.StatusId);
                 await StatusProxy.RemoveStatusAsync(n.StatusId);
                 (await rtt).ForEach(QueueRemoval);
                 if (removal != null)
                 {
                     n = new StatusNotification(removal, false);
                 }
             }
             // post next 
             StatusBroadcaster.Queue(n);
             _signal.Reset();
         }
         if (_isHaltRequested)
         {
             break;
         }
         _signal.Wait();
     }
 }
Example #5
0
 public static async Task<StatusModelNotification> FromStatusNotification(StatusNotification notification, bool isNew)
 {
     var model = notification.Status == null ? null : await StatusModel.Get(notification.Status);
     return new StatusModelNotification(model, notification.IsAdded, isNew, notification.StatusId);
 }
Example #6
0
        public void AcceptStatus(StatusNotification n)
        {
            if (n.IsAdded && this.CheckAcceptStatus(n.Status))
            {
#pragma warning disable 4014
                this.AddStatus(n.Status, true);
#pragma warning restore 4014
            }
            else
            {
                this.RemoveStatus(n.StatusId);
            }
        }