Class TwitchSingleUserEventSocketPool
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<TwitchEventSocket,EventSubSubscription,EventSubSubscription,Boolean,TwitchEventSocket.TwitchEventSocketBuilder>
com.github.twitch4j.eventsub.socket.TwitchSingleUserEventSocketPool
- All Implemented Interfaces:
TransactionalSubscriber<EventSubSubscription,,EventSubSubscription, Boolean> IEventSubSocket,AutoCloseable
public final class TwitchSingleUserEventSocketPool
extends TwitchModuleConnectionPool<TwitchEventSocket,EventSubSubscription,EventSubSubscription,Boolean,TwitchEventSocket.TwitchEventSocketBuilder>
implements IEventSubSocket
A pool for a single user id to subscriptions spread over multiple EventSub websockets.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classTwitchSingleUserEventSocketPool.TwitchSingleUserEventSocketPoolBuilder<C extends TwitchSingleUserEventSocketPool,B extends TwitchSingleUserEventSocketPool.TwitchSingleUserEventSocketPoolBuilder<C, B>> Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C,X, Y, Z, B, C2 extends TwitchModuleConnectionPool<C, X, Y, Z, B>, B2 extends TwitchModuleConnectionPool.TwitchModuleConnectionPoolBuilder<C, X, Y, Z, B, C2, B2>> Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C,S, T, U, C2 extends SubscriptionConnectionPool<C, S, T, U>, B extends SubscriptionConnectionPool.SubscriptionConnectionPoolBuilder<C, S, T, U, C2, B>> Nested classes/interfaces inherited from class com.github.twitch4j.common.pool.AbstractConnectionPool
AbstractConnectionPool.AbstractConnectionPoolBuilder<C,C2 extends AbstractConnectionPool<C>, B extends 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
closed, disposeUnusedConnections, maxSubscriptionsPerConnection, saturatedConnections, subscriptions, unsaturatedConnections -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedTwitchSingleUserEventSocketPool(TwitchSingleUserEventSocketPool.TwitchSingleUserEventSocketPoolBuilder<?, ?> b) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidconnect()Establishes a connection to the EventSub WebSocket server.protected TwitchEventSocketvoidDisconnects from the WebSocket server.protected voiddisposeConnection(TwitchEventSocket connection) @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2CredentialThe default credential (representing the single user) to create eventsub subscriptions with.longprotected EventSubSubscriptiongetRequestFromSubscription(EventSubSubscription eventSubSubscription) protected intgetSubscriptionSize(EventSubSubscription eventSubSubscription) protected EventSubSubscriptionhandleDuplicateSubscription(TwitchEventSocket twitchEventSocket, TwitchEventSocket old, EventSubSubscription eventSubSubscription) protected EventSubSubscriptionhandleSubscription(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) protected BooleanhandleUnsubscription(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) voidReconnects to the WebSocket server.booleanregister(com.github.philippheuer.credentialmanager.domain.OAuth2Credential token, EventSubSubscription sub) Creates (or schedules) an eventsub subscription for this socket.booleanDeletes an eventsub subscription from helix (and this socket).Methods inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
getConnectionEventManager, getDefaultConnectionEventManager, getEventManager, getExecutorMethods inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
close, getConnections, numConnections, numSubscriptions, subscribe, unsubscribeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface com.github.twitch4j.eventsub.socket.IEventSubSocket
getEventManager, register, register, register
-
Constructor Details
-
TwitchSingleUserEventSocketPool
protected TwitchSingleUserEventSocketPool(TwitchSingleUserEventSocketPool.TwitchSingleUserEventSocketPoolBuilder<?, ?> b)
-
-
Method Details
-
createConnection
- Specified by:
createConnectionin classAbstractConnectionPool<TwitchEventSocket>
-
disposeConnection
- Specified by:
disposeConnectionin classAbstractConnectionPool<TwitchEventSocket>
-
handleSubscription
protected EventSubSubscription handleSubscription(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) - Specified by:
handleSubscriptionin classSubscriptionConnectionPool<TwitchEventSocket,EventSubSubscription, EventSubSubscription, Boolean>
-
handleDuplicateSubscription
protected EventSubSubscription handleDuplicateSubscription(TwitchEventSocket twitchEventSocket, TwitchEventSocket old, EventSubSubscription eventSubSubscription) -
handleUnsubscription
protected Boolean handleUnsubscription(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) - Specified by:
handleUnsubscriptionin classSubscriptionConnectionPool<TwitchEventSocket,EventSubSubscription, EventSubSubscription, Boolean>
-
getRequestFromSubscription
protected EventSubSubscription getRequestFromSubscription(EventSubSubscription eventSubSubscription) - Specified by:
getRequestFromSubscriptionin classSubscriptionConnectionPool<TwitchEventSocket,EventSubSubscription, EventSubSubscription, Boolean>
-
getSubscriptionSize
- Specified by:
getSubscriptionSizein classSubscriptionConnectionPool<TwitchEventSocket,EventSubSubscription, EventSubSubscription, Boolean>
-
connect
public void connect()Description copied from interface:IEventSubSocketEstablishes a connection to the EventSub WebSocket server.- Specified by:
connectin interfaceIEventSubSocket- See Also:
-
disconnect
public void disconnect()Description copied from interface:IEventSubSocketDisconnects from the WebSocket server.- Specified by:
disconnectin interfaceIEventSubSocket- See Also:
-
reconnect
public void reconnect()Description copied from interface:IEventSubSocketReconnects to the WebSocket server.- Specified by:
reconnectin interfaceIEventSubSocket- See Also:
-
getSubscriptions
- Specified by:
getSubscriptionsin interfaceIEventSubSocket- Returns:
- the eventsub subscriptions associated with this socket
-
register
public boolean register(com.github.philippheuer.credentialmanager.domain.OAuth2Credential token, EventSubSubscription sub) Description copied from interface:IEventSubSocketCreates (or schedules) an eventsub subscription for this socket.- Specified by:
registerin interfaceIEventSubSocket- Parameters:
token- the token to use for creating this subscription via helixsub- the eventsub subscription to be registered- Returns:
- whether this subscription was not already registered to this pool (and, if the websocket is already connected, whether the subscription was successful)
-
unregister
Description copied from interface:IEventSubSocketDeletes an eventsub subscription from helix (and this socket).- Specified by:
unregisterin interfaceIEventSubSocket- Parameters:
sub- the eventsub subscription to be destroyed- Returns:
- whether the specified subscription was previously registered with this socket
-
getLatency
public long getLatency()- Specified by:
getLatencyin interfaceIEventSubSocket- Returns:
- the most recently measured round-trip latency for the socket(s) in milliseconds, or -1 if unknown
-
builder
-
getDefaultToken
@Nullable public @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultToken()The default credential (representing the single user) to create eventsub subscriptions with.- Specified by:
getDefaultTokenin interfaceIEventSubSocket- Returns:
- the default token to use when creating subscriptions
-