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
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()
void
close()
void
connect()
Establishes a connection to the EventSub WebSocket server.void
Disconnects from the WebSocket server.@Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential
com.github.philippheuer.events4j.core.EventManager
The defaultEventManager
for this connection pool, if specified.long
int
int
void
Reconnects to the WebSocket server.boolean
register
(com.github.philippheuer.credentialmanager.domain.OAuth2Credential credential, 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.twitch4j.eventsub.socket.IEventSubSocket
register, register, register
-
Method Details
-
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:
-
register
public boolean register(com.github.philippheuer.credentialmanager.domain.OAuth2Credential credential, EventSubSubscription sub) Description copied from interface:IEventSubSocket
Creates (or schedules) an eventsub subscription for this socket.- Specified by:
register
in 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: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
-
getSubscriptions
- Specified by:
getSubscriptions
in interfaceIEventSubSocket
- Returns:
- the eventsub subscriptions associated with this socket
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
getDefaultToken
@Nullable public @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultToken()- Specified by:
getDefaultToken
in interfaceIEventSubSocket
- Returns:
- the default token to use when creating subscriptions
-
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
-
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 defaultEventManager
for this connection pool, if specified.- Specified by:
getEventManager
in interfaceIEventSubSocket
- Returns:
- the event manager for eventsub notifications
-