Package com.github.twitch4j.pubsub
Class TwitchPubSubConnectionPool
java.lang.Object
com.github.twitch4j.common.pool.AbstractConnectionPool<C>
com.github.twitch4j.common.pool.SubscriptionConnectionPool<C,X,Y,Z>
com.github.twitch4j.common.pool.TwitchModuleConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean,TwitchPubSubBuilder>
com.github.twitch4j.pubsub.TwitchPubSubConnectionPool
- All Implemented Interfaces:
com.github.twitch4j.common.pool.TransactionalSubscriber<PubSubRequest,PubSubSubscription,java.lang.Boolean>,ITwitchPubSub,java.lang.AutoCloseable
public class TwitchPubSubConnectionPool extends com.github.twitch4j.common.pool.TwitchModuleConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean,TwitchPubSubBuilder> implements ITwitchPubSub
A pool for PubSub connections to help navigate rate-limits.
Warning: Passing a ScheduledThreadPoolExecutor with too small corePoolSize can lead to
connections in the pool not behaving properly. Not specifying an executor allows connections to create their own
at will. If enough connections are made, this could pollute one's runtime environment.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTwitchPubSubConnectionPool.TwitchPubSubConnectionPoolBuilder<C extends TwitchPubSubConnectionPool,B extends TwitchPubSubConnectionPool.TwitchPubSubConnectionPoolBuilder<C,B>>Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
com.github.twitch4j.common.pool.TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C extends java.lang.Object,X extends java.lang.Object,Y extends java.lang.Object,Z extends java.lang.Object,B extends java.lang.Object,C2 extends com.github.twitch4j.common.pool.TwitchModuleConnectionPool<C,X,Y,Z,B>,B2 extends com.github.twitch4j.common.pool.TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C,X,Y,Z,B,C2,B2>>Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
com.github.twitch4j.common.pool.SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C extends java.lang.Object,S extends java.lang.Object,T extends java.lang.Object,U extends java.lang.Object,C2 extends com.github.twitch4j.common.pool.SubscriptionConnectionPool<C,S,T,U>,B extends com.github.twitch4j.common.pool.SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C,S,T,U,C2,B>>Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.AbstractConnectionPool
com.github.twitch4j.common.pool.AbstractConnectionPool.AbstractConnectionPoolBuilder<C extends java.lang.Object,C2 extends com.github.twitch4j.common.pool.AbstractConnectionPool<C>,B extends com.github.twitch4j.common.pool.AbstractConnectionPool.AbstractConnectionPoolBuilder<C,C2,B>> -
Field Summary
Fields inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
advancedConfiguration, executor, proxyConfigFields inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
disposeUnusedConnections, maxSubscriptionsPerConnection, saturatedConnections, subscriptions, unsaturatedConnections -
Constructor Summary
Constructors Modifier Constructor Description protectedTwitchPubSubConnectionPool(TwitchPubSubConnectionPool.TwitchPubSubConnectionPoolBuilder<?,?> b) -
Method Summary
Modifier and Type Method Description static TwitchPubSubConnectionPool.TwitchPubSubConnectionPoolBuilder<?,?>builder()protected TwitchPubSubcreateConnection()protected voiddisposeConnection(TwitchPubSub connection)protected PubSubRequestgetRequestFromSubscription(PubSubSubscription subscription)protected intgetSubscriptionSize(PubSubRequest pubSubRequest)protected PubSubSubscriptionhandleDuplicateSubscription(TwitchPubSub twitchPubSub, TwitchPubSub old, PubSubRequest pubSubRequest)protected PubSubSubscriptionhandleSubscription(TwitchPubSub twitchPubSub, PubSubRequest pubSubRequest)protected java.lang.BooleanhandleUnsubscription(TwitchPubSub twitchPubSub, PubSubSubscription pubSubSubscription)PubSubSubscriptionlistenOnTopic(PubSubRequest request)Send WS Message to subscribe to a topicPubSubSubscriptionsubscribe(PubSubRequest pubSubRequest)booleanunsubscribeFromTopic(PubSubSubscription subscription)Unsubscribe from a topic.Methods inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
createEventManager, getConnectionEventManager, getDefaultConnectionEventManager, getEventManager, getExecutorMethods inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
getConnections, numConnections, numSubscriptions, unsubscribeMethods inherited from class com.github.twitch4j.common.pool.AbstractConnectionPool
closeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.twitch4j.pubsub.ITwitchPubSub
close, getEventManager, listenForAdPropertyRefreshEvents, listenForAdsEvents, listenForAutomodLevelsModificationEvents, listenForAutomodQueueEvents, listenForBitsBadgeEvents, listenForBountyBoardEvents, listenForBroadcastSettingUpdateEvents, listenForCelebrationEvents, listenForChannelBitsLeaderboardEvents, listenForChannelBitsLeaderboardEvents, listenForChannelBitsLeaderboardMonthlyEvents, listenForChannelChatroomEvents, listenForChannelDropEvents, listenForChannelExtensionEvents, listenForChannelPointsRedemptionEvents, listenForChannelPredictionsEvents, listenForChannelPrimeGiftStatusEvents, listenForChannelSquadEvents, listenForChannelSubGiftsEvents, listenForChannelSubLeaderboardEvents, listenForChannelSubLeaderboardEvents, listenForChannelSubLeaderboardMonthlyEvents, listenForChannelUnbanRequestEvents, listenForCheerEvents, listenForCommerceEvents, listenForCommunityBoostEvents, listenForCrowdChantEvents, listenForDashboardActivityFeedEvents, listenForExtensionControlEvents, listenForFollowingEvents, listenForFriendshipEvents, listenForHypeTrainEvents, listenForHypeTrainRewardEvents, listenForLeaderboardEvents, listenForLeaderboardEvents, listenForLeaderboardMonthlyEvents, listenForModerationEvents, listenForModerationEvents, listenForOnsiteNotificationEvents, listenForPollEvents, listenForPresenceEvents, listenForPublicBitEvents, listenForPublicCheerEvents, listenForRadioEvents, listenForRaidEvents, listenForStreamChangeEvents, listenForStreamChatRoomEvents, listenForSubscriptionEvents, listenForUserBitsUpdateEvents, listenForUserCampaignEvents, listenForUserChannelPointsEvents, listenForUserChatroomEvents, listenForUserDropEvents, listenForUserImageUpdateEvents, listenForUserModerationNotificationEvents, listenForUserPredictionsEvents, listenForUserPropertiesUpdateEvents, listenForUserSubscribeEvents, listenForUserUnbanRequestEvents, listenForVideoPlaybackByNameEvents, listenForVideoPlaybackEvents, listenForWatchPartyEvents, listenForWhisperEvents, listenOnTopic, listenOnTopic, listenOnTopic
-
Constructor Details
-
TwitchPubSubConnectionPool
protected TwitchPubSubConnectionPool(TwitchPubSubConnectionPool.TwitchPubSubConnectionPoolBuilder<?,?> b)
-
-
Method Details
-
listenOnTopic
Description copied from interface:ITwitchPubSubSend WS Message to subscribe to a topic- Specified by:
listenOnTopicin interfaceITwitchPubSub- Parameters:
request- Topic- Returns:
- PubSubSubscription to be listened to
-
unsubscribeFromTopic
Description copied from interface:ITwitchPubSubUnsubscribe from a topic. Usage example:PubSubSubscription subscription = twitchPubSub.listenForCheerEvents(...); // ... twitchPubSub.unsubscribeFromTopic(subscription);- Specified by:
unsubscribeFromTopicin interfaceITwitchPubSub- Parameters:
subscription- PubSubSubscription to be unlistened from- Returns:
- whether the subscription was previously subscribed to
-
subscribe
- Specified by:
subscribein interfacecom.github.twitch4j.common.pool.TransactionalSubscriber<PubSubRequest,PubSubSubscription,java.lang.Boolean>- Overrides:
subscribein classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
createConnection
- Specified by:
createConnectionin classcom.github.twitch4j.common.pool.AbstractConnectionPool<TwitchPubSub>
-
disposeConnection
- Specified by:
disposeConnectionin classcom.github.twitch4j.common.pool.AbstractConnectionPool<TwitchPubSub>
-
handleSubscription
protected PubSubSubscription handleSubscription(TwitchPubSub twitchPubSub, PubSubRequest pubSubRequest)- Specified by:
handleSubscriptionin classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
handleDuplicateSubscription
protected PubSubSubscription handleDuplicateSubscription(TwitchPubSub twitchPubSub, TwitchPubSub old, PubSubRequest pubSubRequest)- Specified by:
handleDuplicateSubscriptionin classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
handleUnsubscription
protected java.lang.Boolean handleUnsubscription(TwitchPubSub twitchPubSub, PubSubSubscription pubSubSubscription)- Specified by:
handleUnsubscriptionin classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
getRequestFromSubscription
- Specified by:
getRequestFromSubscriptionin classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
getSubscriptionSize
- Specified by:
getSubscriptionSizein classcom.github.twitch4j.common.pool.SubscriptionConnectionPool<TwitchPubSub,PubSubRequest,PubSubSubscription,java.lang.Boolean>
-
builder
-