Example #1
0
 protected override void OnStop()
 {
     timer.Elapsed -= new ElapsedEventHandler(PushNotificationsToClient);
     Logger.Info($"Disconnected connection id : {NotificationHubConnection.ConnectionId}");
     NotificationHubConnection.Stop();
     Logger.Info("Service stopped");
 }
Example #2
0
        protected async override void OnStart(string[] args)
        {
            await NotificationHubConnection.Start();

            //NotificationHubConnection.Closed += OnNotificationHubConnectionClosed;
            Logger.Info($"Connected connection id : {NotificationHubConnection.ConnectionId}");
            Logger.Info("Service started");
            timer          = new Timer();
            timer.Elapsed += new ElapsedEventHandler(PushNotificationsToClient);
            timer.Interval = Convert.ToDouble(AppConfiguration.NotificationHub_TriggerInterval) * 1000;
            timer.Enabled  = true;
            timer.Start();
        }
Example #3
0
        private void OnNotificationHubConnectionClosed()
        {
            var t = NotificationHubConnection.Start();

            bool result = false;

            t.ContinueWith(task =>
            {
                if (!task.IsFaulted)
                {
                    result = true;
                }
            }).Wait();

            if (!result)
            {
                OnNotificationHubConnectionClosed();
            }
        }