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
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Each WebSocket connection may create a maximum of 300 enabled subscriptions (disabled subscriptions don't count against the limit).static final int
static final String
The WebSocket Server -
Method Summary
Modifier and TypeMethodDescriptionbuilder()
void
close()
void
connect()
Connecting to EventSub-WSvoid
Disconnecting from EventSub-WS@Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential
Default Helix Token@NotNull com.github.philippheuer.events4j.core.EventManager
EventManagerlong
getState()
@Nullable String
The Twitch-assigned id associated with this websocket, which is used when creating eventsub subscriptions via the API.void
Reconnecting to EventSub-WSboolean
register
(com.github.philippheuer.credentialmanager.domain.OAuth2Credential token, EventSubSubscription sub) Creates (or schedules) an eventsub subscription for this socket.boolean
unregister
(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, wait
Methods 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:
connect
in interfaceIEventSubSocket
- See Also:
-
disconnect
public void disconnect()Disconnecting from EventSub-WS- Specified by:
disconnect
in interfaceIEventSubSocket
- See Also:
-
reconnect
public void reconnect()Reconnecting to EventSub-WS- Specified by:
reconnect
in interfaceIEventSubSocket
- See Also:
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
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:
subscription
- 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
-
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
-
getState
-
builder
-
getDefaultToken
@Nullable public @Nullable com.github.philippheuer.credentialmanager.domain.OAuth2Credential getDefaultToken()Default Helix Token- Specified by:
getDefaultToken
in interfaceIEventSubSocket
- Returns:
- the default token to use when creating subscriptions
-
getEventManager
@NotNull public @NotNull com.github.philippheuer.events4j.core.EventManager getEventManager()EventManager- Specified by:
getEventManager
in 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.
-