Beispiel #1
0
 // Token: 0x06001068 RID: 4200 RVA: 0x0003EF00 File Offset: 0x0003D100
 internal void AddRemoteNotificationPayload(RemoteNotificationPayload remoteNotificationPayload)
 {
     lock (this)
     {
         if (this.reloadAll)
         {
             NotificationStatisticsManager.Instance.NotificationReceived(remoteNotificationPayload);
             NotificationStatisticsManager.Instance.NotificationDropped(remoteNotificationPayload, NotificationState.CreatedOrReceived);
         }
         else if (this.queue.Count >= 40)
         {
             NotificationStatisticsManager.Instance.NotificationReceived(remoteNotificationPayload);
             NotificationStatisticsManager.Instance.NotificationDropped(remoteNotificationPayload, NotificationState.CreatedOrReceived);
             NotificationStatisticsManager.Instance.NotificationDropped(this.queue, NotificationState.CreatedOrReceived);
             this.queue.Clear();
             ReloadAllNotificationPayload reloadAllNotificationPayload = new ReloadAllNotificationPayload();
             reloadAllNotificationPayload.Source = new TypeLocation(base.GetType());
             this.queue.Enqueue(reloadAllNotificationPayload);
             NotificationStatisticsManager.Instance.NotificationCreated(reloadAllNotificationPayload);
             this.reloadAll = true;
         }
         else
         {
             this.queue.Enqueue(remoteNotificationPayload);
             NotificationStatisticsManager.Instance.NotificationReceived(remoteNotificationPayload);
         }
     }
 }
Beispiel #2
0
        public virtual void Enqueue(List <NotificationPayloadBase> payloads, IEnumerable <string> channelIds)
        {
            bool flag = false;

            lock (this.syncRoot)
            {
                if (this.TotalPayloads + payloads.Count <= 200)
                {
                    flag = (this.TotalPayloads == 0);
                    foreach (NotificationPayloadBase payload2 in payloads)
                    {
                        this.payloadQueue.Enqueue(new PusherQueuePayload(payload2, channelIds));
                    }
                    NotificationStatisticsManager.Instance.NotificationQueued(payloads);
                }
                else
                {
                    HashSet <string> hashSet = new HashSet <string>();
                    foreach (PusherQueuePayload pusherQueuePayload in this.payloadQueue.Concat(this.inTransitQueue ?? Array <PusherQueuePayload> .Empty).Concat(from payload in payloads
                                                                                                                                                                select new PusherQueuePayload(payload, channelIds)))
                    {
                        hashSet.UnionWith(pusherQueuePayload.ChannelIds);
                    }
                    IEnumerable <NotificationPayloadBase> payloads2 = from p in this.payloadQueue
                                                                      select p.Payload;
                    NotificationStatisticsManager.Instance.NotificationDropped(payloads2, NotificationState.Queued);
                    this.payloadQueue.Clear();
                    this.inTransitQueue = null;
                    ReloadAllNotificationPayload reloadAllNotificationPayload = new ReloadAllNotificationPayload();
                    reloadAllNotificationPayload.Source = new TypeLocation(base.GetType());
                    this.payloadQueue.Enqueue(new PusherQueuePayload(reloadAllNotificationPayload, hashSet));
                    NotificationStatisticsManager.Instance.NotificationCreated(reloadAllNotificationPayload);
                    NotificationStatisticsManager.Instance.NotificationQueued(reloadAllNotificationPayload);
                }
            }
            if (flag)
            {
                this.readyCallback(this);
            }
        }
Beispiel #3
0
        private void WriteNotification(bool asyncOperation)
        {
            if (!this.lockTracker.IsLockOwner())
            {
                throw new OwaInvalidOperationException("A thread that is not the owner of the lock can't call WriteNotification!");
            }
            bool flag = false;

            while (!flag)
            {
                if (this.disposePendingRequest)
                {
                    this.CloseCurrentPendingRequest(asyncOperation, true);
                    return;
                }
                try
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append("[");
                    lock (this.syncRoot)
                    {
                        if (this.payloadList != null)
                        {
                            if (!this.reloadNeeded)
                            {
                                foreach (NotificationPayloadBase notificationPayloadBase in this.payloadList)
                                {
                                    RemoteNotificationPayload remoteNotificationPayload = notificationPayloadBase as RemoteNotificationPayload;
                                    if (remoteNotificationPayload != null)
                                    {
                                        stringBuilder.Append(remoteNotificationPayload.RemotePayload).Append(",");
                                        this.notificationMark += (long)remoteNotificationPayload.NotificationsCount;
                                    }
                                    else
                                    {
                                        stringBuilder.Append(JsonConverter.ToJSON(notificationPayloadBase)).Append(",");
                                        this.notificationMark += 1L;
                                    }
                                }
                                if (stringBuilder.Length > 1)
                                {
                                    stringBuilder.Remove(stringBuilder.Length - 1, 1);
                                    stringBuilder.Append("]");
                                    this.Write(stringBuilder.ToString());
                                }
                                NotificationStatisticsManager.Instance.NotificationDispatched(this.channelId, this.payloadList);
                                this.payloadList.Clear();
                            }
                            else
                            {
                                ReloadAllNotificationPayload payload = new ReloadAllNotificationPayload
                                {
                                    Source = new TypeLocation(base.GetType())
                                };
                                NotificationStatisticsManager.Instance.NotificationCreated(payload);
                                NotificationStatisticsManager.Instance.NotificationDispatched(this.channelId, payload);
                            }
                            this.reloadNeeded = false;
                            this.WriteNotificationMark(this.notificationMark);
                        }
                    }
                }
                finally
                {
                    flag = this.lockTracker.TryReleaseLock();
                }
                if (flag)
                {
                    return;
                }
            }
        }