Пример #1
0
 private void TwitchApiExceptionHandler(object sender, UnhandledExceptionEventArgs args)
 {
     if (args.ExceptionObject is InternalServerErrorException e)
     {
         _logger.LogError($"Caught {nameof(InternalServerErrorException)} exception: {e.Message}{Environment.NewLine}{e.StackTrace}");
         _twitchMonitor.Stop();
         _twitchMonitor.Start();
     }
     else if (args.ExceptionObject is SocketException e2)
     {
         _logger.LogError($"Caught {nameof(SocketException)} exception: {e2.Message}{Environment.NewLine}{e2.StackTrace}");
         _twitchMonitor.Stop();
         _twitchMonitor.Start();
     }
     else if (args.ExceptionObject is HttpRequestException e3)
     {
         _logger.LogError($"Caught {nameof(HttpRequestException)} exception: {e3.Message}{Environment.NewLine}{e3.StackTrace}");
         _twitchMonitor.Stop();
         _twitchMonitor.Start();
     }
     else
     {
         var ex = (Exception)args.ExceptionObject;
         _logger.LogCritical($"Unhandled exception {args.ExceptionObject.GetType().FullName}. {ex.Message}{Environment.NewLine}{ex.StackTrace}");
         Environment.Exit(1);
     }
 }
Пример #2
0
 public void Stop()
 {
     if (LiveStreamMonitor.Enabled)
     {
         Log.Info("LiveStreamMonitor stopped");
         LiveStreamMonitor.Stop();
     }
 }
 internal void Disconnect()
 {
     CloseExcel();
     client.Disconnect();
     monitor.Stop();
     fservice.Stop();
     Console.WriteLine("Disconnecting...");
 }
        // -----
        // General Purpose Functions
        // -----

        public async Task UpdateChannelsToMonitor()
        {
            await GetStreamerIdDictAsync();

            try
            {
                _liveStreamMonitor.SetChannelsById(StreamIdList);
            }
            catch (ArgumentException e)
            {
                Console.WriteLine($"{DateTime.UtcNow.ToString("hh:mm:ss")} [StreamMonoService]: Stopping Live Stream Monitor: {e.Message}");
                if (_liveStreamMonitor.Enabled)
                {
                    _liveStreamMonitor.Stop();
                }
            }
            await GetProfImgUrlsAsync(StreamIdList);

            GetStreamerList();
        }
            public void OnServiceStopped_Raised_When_ServiceStopped()
            {
                var eventRaised = false;

                _liveStreamMonitor = new LiveStreamMonitorService(_api);
                _liveStreamMonitor.SetChannelsById(Utils.CreateListWithEmptyString());
                _liveStreamMonitor.OnServiceStopped += (sender, e) => eventRaised = true;
                _liveStreamMonitor.Start();
                _liveStreamMonitor.Stop();

                Assert.True(eventRaised);
            }
Пример #6
0
 public void Dispose()
 {
     try {
         Service.Stop();
     } catch (Exception e) {
         Console.WriteLine("Service.Stop(); failed");
     }
     try {
         Monitor.Stop();
     } catch (Exception) {
         Console.WriteLine("Monitor.Stop(); failed");
     }
 }
Пример #7
0
        public async static Task UpdateMonitorList()
        {
            twitchService = new TwitchService(_client);
            var records = await twitchService.GetTwitchMonitorList();

            Log.Information($"Twitch Records Retrieved: ${records}");
            List <string> userNameList = new List <string>();

            foreach (var record in records)
            {
                userNameList.Add(record.twitchId);
            }
            userIdList = userNameList;

            if (userIdList.Count >= 1)
            {
                try
                {
                    Monitor.SetChannelsById(userIdList);
                }
                catch (Exception e)
                {
                    Log.Error($"Twitch User Not Found: ${e.Message}");
                    Log.Error(userIdList.ToString());
                }
                if (!twitchMonitorStarted)
                {
                    Log.Information($"Starting Twitch Monitor for {userIdList.Count} users");
                    Monitor.Start();
                    Monitor.OnStreamOnline += twitchService.Monitor_OnStreamOnline;
                    twitchMonitorStarted    = true;
                }
            }
            else
            {
                if (twitchMonitorStarted)
                {
                    Monitor.Stop();
                }
            }
        }
Пример #8
0
 public void Dispose()
 {
     Monitor.Stop();
 }
            public void Stop_Throws_InvalidOperationException_When_ServiceAlreadyStopped()
            {
                _liveStreamMonitor = new LiveStreamMonitorService(_api);

                AssertException.Throws <InvalidOperationException>(AlreadyStoppedExceptionMessage, () => _liveStreamMonitor.Stop());
            }
Пример #10
0
 public void StopMonitoring()
 {
     Monitor.Stop();
 }