Exemple #1
0
        /// <summary>
        /// Sets channels by to monitor.
        /// </summary>
        /// <exception cref="ArgumentNullException">When <paramref name="channelsToMonitor"/> is null.</exception>
        /// <exception cref="ArgumentException">When <paramref name="channelsToMonitor"/> is empty.</exception>
        /// <param name="channelsToMonitor">The channels to monitor.</param>
        protected virtual void SetChannels(List <string> channelsToMonitor)
        {
            if (channelsToMonitor == null)
            {
                throw new ArgumentNullException(nameof(channelsToMonitor));
            }

            if (channelsToMonitor.Count == 0)
            {
                throw new ArgumentException("The provided list is empty.", nameof(channelsToMonitor));
            }

            ChannelsToMonitor = channelsToMonitor;

            OnChannelsSet?.Invoke(this, new OnChannelsSetArgs {
                Channels = channelsToMonitor
            });
        }
Exemple #2
0
        public UnityLiveStreamMonitor(ITwitchAPI api, int checkIntervalSeconds = 60, int maxStreamRequestCountPerRequest = 100) : base(api, checkIntervalSeconds, maxStreamRequestCountPerRequest)
        {
            ThreadDispatcher.EnsureCreated();

            base.OnStreamOnline   += ((object sender, OnStreamOnlineArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamOnline?.Invoke(sender, e)); });
            base.OnStreamOffline  += ((object sender, OnStreamOfflineArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamOffline?.Invoke(sender, e)); });
            base.OnStreamUpdate   += ((object sender, OnStreamUpdateArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamUpdate?.Invoke(sender, e)); });
            base.OnServiceStarted += ((object sender, OnServiceStartedArgs e) => { ThreadDispatcher.Enqueue(() => OnServiceStarted?.Invoke(sender, e)); });
            base.OnServiceStopped += ((object sender, OnServiceStoppedArgs e) => { ThreadDispatcher.Enqueue(() => OnServiceStopped?.Invoke(sender, e)); });
            base.OnChannelsSet    += ((object sender, OnChannelsSetArgs e) => { ThreadDispatcher.Enqueue(() => OnChannelsSet?.Invoke(sender, e)); });
        }