Package com.gmt2001.twitch.eventsub
Class EventSub
java.lang.Object
java.util.concurrent.SubmissionPublisher<EventSubInternalEvent>
com.gmt2001.twitch.eventsub.EventSub
- All Implemented Interfaces:
WsClientFrameHandler
,AutoCloseable
,Flow.Publisher<EventSubInternalEvent>
,Listener
public final class EventSub
extends SubmissionPublisher<EventSubInternalEvent>
implements WsClientFrameHandler, Listener
Manages EventSub subscriptions
- Author:
- gmt2001
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
debug()
Indicates if EventSub debug output is enabledstatic void
Logs a debug message for EventSubstatic void
Logs a debug message for EventSubDeletes a subscriptionvoid
handleFrame
(ChannelHandlerContext ctx, WebSocketFrame frame) Handles the WebSocket frame and sends a response back to the server, if necessaryvoid
Handles the handshake complete eventstatic EventSub
instance()
Singleton instance getter.static String
The default moderator user idvoid
onClose()
Handles the channel closing for any reason.void
Restarts EventSub when the API OAuth is re-authorized manuallystatic ZonedDateTime
Parses a date from an EventSub message into aZonedDateTime
void
Restarts the EventSub connectionvoid
Refreshes the internal list of existing subscriptionsReturns the WebSocket session IDvoid
shutdown()
Shuts down EventSubGets all current EventSub subscriptionsMethods inherited from class java.util.concurrent.SubmissionPublisher
close, closeExceptionally, consume, estimateMaximumLag, estimateMinimumDemand, getClosedException, getExecutor, getMaxBufferCapacity, getNumberOfSubscribers, getSubscribers, hasSubscribers, isClosed, isSubscribed, offer, offer, submit, subscribe
-
Method Details
-
instance
Singleton instance getter.- Returns:
-
moderatorUserId
The default moderator user id- Returns:
-
debug
public static boolean debug()Indicates if EventSub debug output is enabled- Returns:
-
debug
Logs a debug message for EventSub- Parameters:
message
- The message to log
-
debug
Logs a debug message for EventSub- Parameters:
message
- The message to logex
- The exception to log
-
subscriptions
Gets all current EventSub subscriptions- Returns:
-
sessionId
Returns the WebSocket session ID- Returns:
-
deleteSubscription
Deletes a subscription- Parameters:
id
- The id of the subscription to delete- Returns:
-
refreshSubscriptions
public void refreshSubscriptions()Refreshes the internal list of existing subscriptions -
parseDate
Parses a date from an EventSub message into aZonedDateTime
- Parameters:
date
- A date string to parse in RFC3339 format- Returns:
-
onTwitchOAuthReauthorizedEvent
Restarts EventSub when the API OAuth is re-authorized manually- Parameters:
event
- The event object
-
reconnect
public void reconnect()Restarts the EventSub connection -
handleFrame
Description copied from interface:WsClientFrameHandler
Handles the WebSocket frame and sends a response back to the server, if necessary- Specified by:
handleFrame
in interfaceWsClientFrameHandler
- Parameters:
ctx
- TheChannelHandlerContext
of the sessionframe
- TheWebSocketFrame
to process
-
handshakeComplete
Description copied from interface:WsClientFrameHandler
Handles the handshake complete event- Specified by:
handshakeComplete
in interfaceWsClientFrameHandler
- Parameters:
ctx
- TheChannelHandlerContext
of the session
-
onClose
public void onClose()Description copied from interface:WsClientFrameHandler
Handles the channel closing for any reason.- Specified by:
onClose
in interfaceWsClientFrameHandler
-
shutdown
public void shutdown()Shuts down EventSub
-