Class TwitchEventSocket
java.lang.Object
com.github.twitch4j.eventsub.socket.TwitchEventSocket
- All Implemented Interfaces:
IEventSubSocket,AutoCloseable
A single EventSub websocket for a single user id.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intEach WebSocket connection may create a maximum of 300 enabled subscriptions (disabled subscriptions don't count against the limit).static final intstatic final StringThe WebSocket Server -
Method Summary
Modifier and TypeMethodDescriptionbuilder()voidclose()voidconnect()Connecting to EventSub-WSvoidDisconnecting from EventSub-WS@Nullable com.github.philippheuer.credentialmanager.domain.OAuth2CredentialDefault Helix Token@NotNull com.github.philippheuer.events4j.core.EventManagerEventManagerlonggetState()@Nullable StringThe Twitch-assigned id associated with this websocket, which is used when creating eventsub subscriptions via the API.voidReconnecting to EventSub-WSbooleanregister(com.github.philippheuer.credentialmanager.domain.OAuth2Credential token, EventSubSubscription sub) Creates (or schedules) an eventsub subscription for this socket.booleanunregister(EventSubSubscription subscription) 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, waitMethods inherited from interface com.github.twitch4j.eventsub.socket.IEventSubSocket
register, register, register
-
Field Details
-
REQUIRED_THREAD_COUNT
public static final int REQUIRED_THREAD_COUNT- See Also:
-
MAX_SUBSCRIPTIONS_PER_SOCKET
public static final int MAX_SUBSCRIPTIONS_PER_SOCKETEach WebSocket connection may create a maximum of 300 enabled subscriptions (disabled subscriptions don't count against the limit).- See Also:
-
WEB_SOCKET_SERVER
The WebSocket Server- See Also:
-
-
Method Details
-
connect
public void connect()Connecting to EventSub-WS- Specified by:
connectin interfaceIEventSubSocket- See Also:
-
disconnect
public void disconnect()Disconnecting from EventSub-WS- Specified by:
disconnectin interfaceIEventSubSocket- See Also:
-
reconnect
public void reconnect()Reconnecting to EventSub-WS- Specified by:
reconnectin interfaceIEventSubSocket- See Also:
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
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:
subscription- 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
-
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
-
getState
-
builder
-
getDefaultToken
@Nullable public @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultToken()Default Helix Token- Specified by:
getDefaultTokenin interfaceIEventSubSocket- Returns:
- the default token to use when creating subscriptions
-
getEventManager
@NotNull public @NotNull com.github.philippheuer.events4j.core.EventManager getEventManager()EventManager- Specified by:
getEventManagerin interfaceIEventSubSocket- Returns:
- the event manager for eventsub notifications
-
getWebsocketId
The Twitch-assigned id associated with this websocket, which is used when creating eventsub subscriptions via the API.
-