Package com.github.twitch4j
Class TwitchClientHelper
java.lang.Object
com.github.twitch4j.TwitchClientHelper
- All Implemented Interfaces:
java.lang.AutoCloseable
public class TwitchClientHelper
extends java.lang.Object
implements java.lang.AutoCloseable
A helper class that covers a few basic use cases of most library users
-
Field Summary
Fields Modifier and Type Field Description static intREQUIRED_THREAD_COUNT -
Constructor Summary
Constructors Constructor Description TwitchClientHelper(com.github.twitch4j.helix.TwitchHelix twitchHelix, com.github.philippheuer.events4j.core.EventManager eventManager, java.util.concurrent.ScheduledThreadPoolExecutor executor)Constructor -
Method Summary
Modifier and Type Method Description voidclose()ClosevoiddisableFollowEventListener(java.lang.Iterable<java.lang.String> channelNames)Disable Follow Listener for the given channel namesvoiddisableFollowEventListener(java.lang.String channelName)Disable Follow ListenerbooleandisableFollowEventListenerForId(java.lang.String channelId)Disable Follow Listener, without invoking a Helix API callvoiddisableStreamEventListener(java.lang.Iterable<java.lang.String> channelNames)Disable StreamEvent Listener for the given channel namesvoiddisableStreamEventListener(java.lang.String channelName)Disable StreamEvent ListenerbooleandisableStreamEventListenerForId(java.lang.String channelId)Disable StreamEventListener, without invoking a Helix API calljava.util.Collection<com.github.twitch4j.helix.domain.User>enableFollowEventListener(java.lang.Iterable<java.lang.String> channelNames)Enable Follow Listener for the given channel names@Nullable com.github.twitch4j.helix.domain.UserenableFollowEventListener(java.lang.String channelName)Follow ListenerbooleanenableFollowEventListener(java.lang.String channelId, java.lang.String channelName)Enable Follow Listener, without invoking a Helix API calljava.util.Collection<com.github.twitch4j.helix.domain.User>enableStreamEventListener(java.lang.Iterable<java.lang.String> channelNames)Enable StreamEvent Listener for the given channel names@Nullable com.github.twitch4j.helix.domain.UserenableStreamEventListener(java.lang.String channelName)Enable StreamEvent ListenerbooleanenableStreamEventListener(java.lang.String channelId, java.lang.String channelName)Enable StreamEvent Listener, without invoking a Helix API calljava.util.Optional<ChannelCache>getCachedInformation(java.lang.String channelId)Get cached information for a channel's stream status and follower count.voidsetThreadDelay(long threadDelay)UpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e. stream status and followers)voidsetThreadRate(long threadRate)UpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e. stream status and followers)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
REQUIRED_THREAD_COUNT
public static final int REQUIRED_THREAD_COUNT- See Also:
- Constant Field Values
-
-
Constructor Details
-
TwitchClientHelper
public TwitchClientHelper(com.github.twitch4j.helix.TwitchHelix twitchHelix, com.github.philippheuer.events4j.core.EventManager eventManager, java.util.concurrent.ScheduledThreadPoolExecutor executor)Constructor- Parameters:
twitchHelix- TwitchHelixeventManager- EventManagerexecutor- ScheduledThreadPoolExecutor
-
-
Method Details
-
enableStreamEventListener
@Nullable public @Nullable com.github.twitch4j.helix.domain.User enableStreamEventListener(java.lang.String channelName)Enable StreamEvent Listener- Parameters:
channelName- Channel Name
-
enableStreamEventListener
public java.util.Collection<com.github.twitch4j.helix.domain.User> enableStreamEventListener(java.lang.Iterable<java.lang.String> channelNames)Enable StreamEvent Listener for the given channel names- Parameters:
channelNames- the channel names to be added
-
enableStreamEventListener
public boolean enableStreamEventListener(java.lang.String channelId, java.lang.String channelName)Enable StreamEvent Listener, without invoking a Helix API call- Parameters:
channelId- Channel IdchannelName- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableStreamEventListener
public void disableStreamEventListener(java.lang.String channelName)Disable StreamEvent Listener- Parameters:
channelName- Channel Name
-
disableStreamEventListener
public void disableStreamEventListener(java.lang.Iterable<java.lang.String> channelNames)Disable StreamEvent Listener for the given channel names- Parameters:
channelNames- the channel names to be removed
-
disableStreamEventListenerForId
public boolean disableStreamEventListenerForId(java.lang.String channelId)Disable StreamEventListener, without invoking a Helix API call- Parameters:
channelId- Channel Id- Returns:
- true if the channel was removed, false otherwise
-
enableFollowEventListener
@Nullable public @Nullable com.github.twitch4j.helix.domain.User enableFollowEventListener(java.lang.String channelName)Follow Listener- Parameters:
channelName- Channel Name
-
enableFollowEventListener
public java.util.Collection<com.github.twitch4j.helix.domain.User> enableFollowEventListener(java.lang.Iterable<java.lang.String> channelNames)Enable Follow Listener for the given channel names- Parameters:
channelNames- the channel names to be added
-
enableFollowEventListener
public boolean enableFollowEventListener(java.lang.String channelId, java.lang.String channelName)Enable Follow Listener, without invoking a Helix API call- Parameters:
channelId- Channel IdchannelName- Channel Name- Returns:
- true if the channel was added, false otherwise
-
disableFollowEventListener
public void disableFollowEventListener(java.lang.String channelName)Disable Follow Listener- Parameters:
channelName- Channel Name
-
disableFollowEventListener
public void disableFollowEventListener(java.lang.Iterable<java.lang.String> channelNames)Disable Follow Listener for the given channel names- Parameters:
channelNames- the channel names to be removed
-
disableFollowEventListenerForId
public boolean disableFollowEventListenerForId(java.lang.String channelId)Disable Follow Listener, without invoking a Helix API call- Parameters:
channelId- Channel Id- Returns:
- true when a previously-tracked channel was removed, false otherwise
-
setThreadRate
public void setThreadRate(long threadRate)UpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e. stream status and followers)- Parameters:
threadRate- the maximum rate of api calls per second
-
setThreadDelay
public void setThreadDelay(long threadDelay)UpdatesExponentialBackoffStrategy.getBaseMillis()for each of the independent listeners (i.e. stream status and followers)- Parameters:
threadDelay- the minimum milliseconds delay between each api call
-
getCachedInformation
Get cached information for a channel's stream status and follower count.For this information to be valid, the respective event listeners need to be enabled for the channel.
For thread safety, the setters on this object should not be used; only getters.
- Parameters:
channelId- The ID of the channel whose cache is to be retrieved.- Returns:
- ChannelCache in an optional wrapper.
-
close
public void close()Close- Specified by:
closein interfacejava.lang.AutoCloseable
-