예제 #1
0
            public async override void Run()
            {
                if (AppSettings.Notifying)
                {
                    try
                    {
                        if (!ExtNotifications.NotificationHttpRequestInProgress && !_notificationStackExecutionInProgress)
                        {
                            _notificationStackExecutionInProgress = true;
                            var noteText = await ExtWebInterface.GetNotificationText("https://www.bitchute.com/notifications/");

                            var noteList = await ExtNotifications.DecodeHtmlNotifications(noteText);

                            ExtNotifications.SendNotifications(noteList);
                            _notificationStackExecutionInProgress = false;
                        }
                    }
                    catch {   }
                }
            }
예제 #2
0
        /// <summary>
        /// starts/restarts the notifications,
        /// takes a ms int as the delay for starting,
        /// if this is called with no delay TheFragment5 sometimes
        /// is null or has issues when it's methods are called
        /// immediately after the app initially loads.
        ///
        /// Once the notifications are started this loop returns
        /// and invokes a long running TimerTask
        /// The reason for this is because the loop is
        /// stopping after a while so I am moving to a timer
        /// system for the long running task to see if that
        /// will prevent the loop from breaking.
        /// </summary>
        public static async void StartNotificationLoop(int delay, List <ExtNotifications.CustomNotification> initialNotifications = null, bool afterLogin = false)
        {
            NotificationLoopStartTimesInvoked++;
            //wait on a delay so that the cookie is ready when we make
            //httprequest for the notifications
            await Task.Delay(delay);

            //use a while loop to start the notifications
            //they move over to a service timer eventually to prevent the loop from breaking
            while (AppSettings.Notifying)
            {
                if (!ExtNotifications.NotificationHttpRequestInProgress && !_notificationStackExecutionInProgress && AppState.UserIsLoggedIn)
                {
                    if (initialNotifications == null)
                    {
                        _notificationStackExecutionInProgress = true;
                        var noteText = await ExtWebInterface.GetNotificationText("https://www.bitchute.com/notifications/");

                        var noteList = await ExtNotifications.DecodeHtmlNotifications(noteText);

                        if (noteList.Count > 0)
                        {
                            ExtNotifications.SendNotifications(noteList);
                            NotificationsHaveBeenSent = true;
                        }
                        _notificationStackExecutionInProgress = false;
                    }
                    else
                    {
                        ExtNotifications.SendNotifications(initialNotifications);
                    }
                }
                if (NotificationsHaveBeenSent)
                {
                    //check to make sure the timer isn't already started or the app will crash
                    if (!MainPlaybackSticky._notificationLongTimerSet)
                    {
                        try
                        {
                            //after the initial notifications are sent, start the long running service timer task
                            _timer.ScheduleAtFixedRate(_extTimerTask, 500000, 780000); // 780000
                            _notificationLongTimerSet = true;
                            return;
                        }
                        catch { }
                    }
                }
                if (NotificationLoopStartTimesInvoked > 1)
                {
                    NotificationLoopStartTimesInvoked--; break;
                }
                else if (!AppState.UserIsLoggedIn)
                {
                    await Task.Delay(220000);
                }
                //user is logged in but has not yet received a notification
                else
                {
                    await Task.Delay(220000);
                }
            }
        }