예제 #1
0
        public virtual bool QueueNotification(Notification notification, bool countsAsRequeue = true, bool ignoreStoppingChannel = false)
        {
            if (this.CancelToken.IsCancellationRequested && !ignoreStoppingChannel)
            {
                Events.RaiseChannelException(new ObjectDisposedException("Channel", "Channel has already been signaled to stop"), this.PlatformType, notification);
                return(false);
            }

            //If the count is -1, it can be queued infinitely, otherwise check that it's less than the max
            if (this.ServiceSettings.MaxNotificationRequeues < 0 || notification.QueuedCount <= this.ServiceSettings.MaxNotificationRequeues)
            {
                //Reset the Enqueued time in case this is a requeue
                notification.EnqueuedTimestamp = DateTime.UtcNow;

                //Increase the queue counter
                if (countsAsRequeue)
                {
                    notification.QueuedCount++;
                }

                queuedNotifications.Enqueue(notification);

                //Signal a possibly wait-stated Sender loop that there's work to do
                waitQueuedNotification.Set();

                return(true);
            }
            else
            {
                Log.Info("Notification ReQueued Too Many Times: {0}", notification.QueuedCount);
                this.Events.RaiseNotificationSendFailure(notification, new MaxSendAttemptsReachedException());
                return(false);
            }
        }
예제 #2
0
        public void RegisterProxyHandler(ChannelEvents proxy)
        {
            this.OnChannelException += new ChannelExceptionDelegate((exception) => proxy.RaiseChannelException(exception));

            this.OnNotificationSendFailure += new NotificationSendFailureDelegate((notification, exception) => proxy.RaiseNotificationSendFailure(notification, exception));

            this.OnNotificationSent += new NotificationSentDelegate((notification) => proxy.RaiseNotificationSent(notification));

            this.OnDeviceSubscriptionExpired += new DeviceSubscriptionExpired((platform, deviceInfo) => proxy.RaiseDeviceSubscriptionExpired(platform, deviceInfo));

            this.OnDeviceSubscriptionIdChanged += new DeviceSubscriptionIdChanged((platform, oldDeviceInfo, newDeviceInfo) => proxy.RaiseDeviceSubscriptionIdChanged(platform, oldDeviceInfo, newDeviceInfo));
        }
예제 #3
0
        public void QueueNotification(Notification notification)
        {
            if (this.cancelTokenSource.IsCancellationRequested)
            {
                Events.RaiseChannelException(new ObjectDisposedException("Service", "Service has already been signaled to stop"), this.Platform, notification);
                return;
            }

            notification.EnqueuedTimestamp = DateTime.UtcNow;

            queuedNotifications.Enqueue(notification);
        }
예제 #4
0
        public void UnRegisterProxyHandler(ChannelEvents proxy)
        {
            this.OnChannelCreated -= new ChannelCreatedDelegate((platformType, newCount) => proxy.RaiseChannelCreated(platformType, newCount));

            this.OnChannelDestroyed -= new ChannelDestroyedDelegate((platformType, newCount) => proxy.RaiseChannelDestroyed(platformType, newCount));

            this.OnChannelException -= new ChannelExceptionDelegate((exception, platformType, notification) => proxy.RaiseChannelException(exception, platformType, notification));

            this.OnNotificationSendFailure -= new NotificationSendFailureDelegate((notification, exception) => proxy.RaiseNotificationSendFailure(notification, exception));

            this.OnNotificationSent -= new NotificationSentDelegate((notification) => proxy.RaiseNotificationSent(notification));

            this.OnDeviceSubscriptionExpired -= new DeviceSubscriptionExpired((platform, deviceInfo, notification) => proxy.RaiseDeviceSubscriptionExpired(platform, deviceInfo, notification));

            this.OnDeviceSubscriptionIdChanged -= new DeviceSubscriptionIdChanged((platform, oldDeviceInfo, newDeviceInfo, notification) => proxy.RaiseDeviceSubscriptionIdChanged(platform, oldDeviceInfo, newDeviceInfo, notification));
        }
예제 #5
0
        public void UnRegisterProxyHandler(ChannelEvents proxy)
        {
            this.OnChannelCreated -= new ChannelCreatedDelegate((platformType, newCount) => proxy.RaiseChannelCreated(platformType, newCount));

            this.OnChannelDestroyed -= new ChannelDestroyedDelegate((platformType, newCount) => proxy.RaiseChannelDestroyed(platformType, newCount));

            this.OnChannelException -= new ChannelExceptionDelegate((exception, platformType, notification) => proxy.RaiseChannelException(exception, platformType, notification));

            this.OnNotificationSendFailure -= new NotificationSendFailureDelegate((notification, exception) => proxy.RaiseNotificationSendFailure(notification, exception));

            this.OnNotificationSent -= new NotificationSentDelegate((notification) => proxy.RaiseNotificationSent(notification));

            this.OnDeviceSubscriptionExpired -= new DeviceSubscriptionExpired((platform, deviceInfo, notification) => proxy.RaiseDeviceSubscriptionExpired(platform, deviceInfo, notification));

            this.OnDeviceSubscriptionIdChanged -= new DeviceSubscriptionIdChanged((platform, oldDeviceInfo, newDeviceInfo, notification) => proxy.RaiseDeviceSubscriptionIdChanged(platform, oldDeviceInfo, newDeviceInfo, notification));
        }
예제 #6
0
        public void RegisterProxyHandler(ChannelEvents proxy)
        {
            this.OnChannelException += new ChannelExceptionDelegate((exception, notification) => proxy.RaiseChannelException(exception, notification));

            this.OnNotificationSendFailure += new NotificationSendFailureDelegate((notification, exception) => proxy.RaiseNotificationSendFailure(notification, exception));

            this.OnNotificationSent += new NotificationSentDelegate((notification) => proxy.RaiseNotificationSent(notification));

            this.OnDeviceSubscriptionExpired += new DeviceSubscriptionExpired((platform, deviceInfo, notification) => proxy.RaiseDeviceSubscriptionExpired(platform, deviceInfo, notification));

            this.OnDeviceSubscriptionIdChanged += new DeviceSubscriptionIdChanged((platform, oldDeviceInfo, newDeviceInfo, notification) => proxy.RaiseDeviceSubscriptionIdChanged(platform, oldDeviceInfo, newDeviceInfo, notification));
        }