/// <summary> Sets the list of channels to monitor by userid </summary> /// <param name="userids">List of channels to monitor as userids</param> public void SetStreamsByUserId(List <string> userids) { _channelIds = userids; _channelIds.ForEach(x => { if (!_statuses.ContainsKey(x)) { _statuses.Add(x, null); } }); //The following is done in this way due to IEnumerables not allowing //for items being removed while doing iteration var toRemove = new List <string>(); _statuses.Keys.ToList().ForEach(x => { if (!_channelIds.Contains(x)) { toRemove.Add(x); } }); toRemove.ForEach(x => { _statuses.Remove(x); }); OnStreamsSet?.Invoke(this, new OnStreamsSetArgs { ChannelIds = ChannelIds, Channels = _channelToId, CheckIntervalSeconds = CheckIntervalSeconds }); }
/// <summary> Sets the list of channels to monitor by username </summary> /// <param name="userids">List of channels to monitor as userids</param> public void SetStreamsByUserId(List <string> userids) { _channels = userids; _identifierType = StreamIdentifierType.UserIds; OnStreamsSet?.Invoke(this, new OnStreamsSetArgs { Channels = Channels, IdentifierType = IdentifierType, CheckIntervalSeconds = CheckIntervalSeconds }); }
/// <summary> Sets the list of channels to monitor by username </summary> /// <param name="usernames">List of channels to monitor as usernames</param> public void SetStreamsByUsername(List <string> usernames) { _statuses = new Dictionary <string, bool>(); _channels = usernames; _identifierType = StreamIdentifierType.Usernames; OnStreamsSet?.Invoke(this, new OnStreamsSetArgs { Channels = Channels, IdentifierType = IdentifierType, CheckIntervalSeconds = CheckIntervalSeconds }); }
public UnityLiveStreamMonitor(ITwitchAPI api, int checkIntervalSeconds = 60, bool checkStatusOnStart = true, bool invokeEventsOnStart = false) : base(api, checkIntervalSeconds, checkStatusOnStart, invokeEventsOnStart) { 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.OnStreamMonitorStarted += ((object sender, OnStreamMonitorStartedArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamMonitorStarted?.Invoke(sender, e)); }); base.OnStreamMonitorEnded += ((object sender, OnStreamMonitorEndedArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamMonitorEnded?.Invoke(sender, e)); }); base.OnStreamsSet += ((object sender, OnStreamsSetArgs e) => { ThreadDispatcher.Enqueue(() => OnStreamsSet?.Invoke(sender, e)); }); }
public UnityFollowerService(ITwitchAPI api, int checkIntervalSeconds = 60, bool checkStatusOnStart = true, bool invokeEventsOnStart = false) : base(api, checkIntervalSeconds, checkStatusOnStart, invokeEventsOnStart) { _threadDispatcher = new GameObject("ThreadDispatcher"); _threadDispatcher.AddComponent <ThreadDispatcher>(); UnityEngine.Object.DontDestroyOnLoad(_threadDispatcher); base.OnStreamOnline += ((object sender, OnStreamOnlineArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamOnline?.Invoke(sender, e)); }); base.OnStreamOffline += ((object sender, OnStreamOfflineArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamOffline?.Invoke(sender, e)); }); base.OnStreamUpdate += ((object sender, OnStreamUpdateArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamUpdate?.Invoke(sender, e)); }); base.OnStreamMonitorStarted += ((object sender, OnStreamMonitorStartedArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamMonitorStarted?.Invoke(sender, e)); }); base.OnStreamMonitorEnded += ((object sender, OnStreamMonitorEndedArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamMonitorEnded?.Invoke(sender, e)); }); base.OnStreamsSet += ((object sender, OnStreamsSetArgs e) => { ThreadDispatcher.Instance().Enqueue(() => OnStreamsSet?.Invoke(sender, e)); }); }