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
Modifier and TypeClassDescriptionstatic class
TwitchSingleUserEventSocketPool.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, proxyConfig
Fields inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
closed, disposeUnusedConnections, maxSubscriptionsPerConnection, saturatedConnections, subscriptions, unsaturatedConnections
-
Constructor Summary
ModifierConstructorDescriptionprotected
TwitchSingleUserEventSocketPool
(TwitchSingleUserEventSocketPool.TwitchSingleUserEventSocketPoolBuilder<?, ?> b) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
void
connect()
Establishes a connection to the EventSub WebSocket server.protected TwitchEventSocket
void
Disconnects from the WebSocket server.protected void
disposeConnection
(TwitchEventSocket connection) @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential
The default credential (representing the single user) to create eventsub subscriptions with.long
protected EventSubSubscription
getRequestFromSubscription
(EventSubSubscription eventSubSubscription) protected int
getSubscriptionSize
(EventSubSubscription eventSubSubscription) protected EventSubSubscription
handleDuplicateSubscription
(TwitchEventSocket twitchEventSocket, TwitchEventSocket old, EventSubSubscription eventSubSubscription) protected EventSubSubscription
handleSubscription
(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) protected Boolean
handleUnsubscription
(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) void
Reconnects to the WebSocket server.boolean
register
(com.github.philippheuer.credentialmanager.domain.OAuth2Credential token, EventSubSubscription sub) Creates (or schedules) an eventsub subscription for this socket.boolean
Deletes an eventsub subscription from helix (and this socket).Methods inherited from class com.github.twitch4j.common.pool.TwitchModuleConnectionPool
getConnectionEventManager, getDefaultConnectionEventManager, getEventManager, getExecutor
Methods inherited from class com.github.twitch4j.common.pool.SubscriptionConnectionPool
close, getConnections, numConnections, numSubscriptions, subscribe, unsubscribe
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.AutoCloseable
close
Methods 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:
createConnection
in classAbstractConnectionPool<TwitchEventSocket>
-
disposeConnection
- Specified by:
disposeConnection
in classAbstractConnectionPool<TwitchEventSocket>
-
handleSubscription
protected EventSubSubscription handleSubscription(TwitchEventSocket twitchEventSocket, EventSubSubscription eventSubSubscription) - Specified by:
handleSubscription
in 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:
handleUnsubscription
in classSubscriptionConnectionPool<TwitchEventSocket,
EventSubSubscription, EventSubSubscription, Boolean>
-
getRequestFromSubscription
protected EventSubSubscription getRequestFromSubscription(EventSubSubscription eventSubSubscription) - Specified by:
getRequestFromSubscription
in classSubscriptionConnectionPool<TwitchEventSocket,
EventSubSubscription, EventSubSubscription, Boolean>
-
getSubscriptionSize
- Specified by:
getSubscriptionSize
in classSubscriptionConnectionPool<TwitchEventSocket,
EventSubSubscription, EventSubSubscription, Boolean>
-
connect
public void connect()Description copied from interface:IEventSubSocket
Establishes a connection to the EventSub WebSocket server.- Specified by:
connect
in interfaceIEventSubSocket
- See Also:
-
disconnect
public void disconnect()Description copied from interface:IEventSubSocket
Disconnects from the WebSocket server.- Specified by:
disconnect
in interfaceIEventSubSocket
- See Also:
-
reconnect
public void reconnect()Description copied from interface:IEventSubSocket
Reconnects to the WebSocket server.- Specified by:
reconnect
in interfaceIEventSubSocket
- See Also:
-
getSubscriptions
- Specified by:
getSubscriptions
in 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:IEventSubSocket
Creates (or schedules) an eventsub subscription for this socket.- Specified by:
register
in 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:IEventSubSocket
Deletes an eventsub subscription from helix (and this socket).- Specified by:
unregister
in 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:
getLatency
in 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:
getDefaultToken
in interfaceIEventSubSocket
- Returns:
- the default token to use when creating subscriptions
-