Class TwitchEventSocketPool
java.lang.Object
com.github.twitch4j.eventsub.socket.TwitchEventSocketPool
- All Implemented Interfaces:
IEventSubSocket,AutoCloseable
A pool for EventSub websocket subscriptions across multiple users.
Should not be used with the "conduit" transport type.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidclose()voidconnect()Establishes a connection to the EventSub WebSocket server.voidDisconnects from the WebSocket server.@Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credentialcom.github.philippheuer.events4j.core.EventManagerThe defaultEventManagerfor this connection pool, if specified.longintintvoidReconnects to the WebSocket server.booleanregister(com.github.philippheuer.credentialmanager.domain.OAuth2Credential credential, EventSubSubscription sub) Creates (or schedules) an eventsub subscription for this socket.booleanDeletes an eventsub subscription from helix (and this socket).Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.twitch4j.eventsub.socket.IEventSubSocket
register, register, register
-
Method Details
-
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:
-
register
public boolean register(com.github.philippheuer.credentialmanager.domain.OAuth2Credential credential, EventSubSubscription sub) Description copied from interface:IEventSubSocketCreates (or schedules) an eventsub subscription for this socket.- Specified by:
registerin interfaceIEventSubSocket- Parameters:
credential- 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
-
getSubscriptions
- Specified by:
getSubscriptionsin interfaceIEventSubSocket- Returns:
- the eventsub subscriptions associated with this socket
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
getDefaultToken
@Nullable public @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultToken()- Specified by:
getDefaultTokenin interfaceIEventSubSocket- Returns:
- the default token to use when creating subscriptions
-
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
-
numConnections
public int numConnections()- Returns:
- the number of open connections held by this pool.
-
numSubscriptions
public int numSubscriptions()- Returns:
- the total number of subscriptions held by all connections.
-
builder
-
getEventManager
public com.github.philippheuer.events4j.core.EventManager getEventManager()The defaultEventManagerfor this connection pool, if specified.- Specified by:
getEventManagerin interfaceIEventSubSocket- Returns:
- the event manager for eventsub notifications
-