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 booleandebug()Indicates if EventSub debug output is enabledstatic voidLogs a debug message for EventSubstatic voidLogs a debug message for EventSubDeletes a subscriptionvoidhandleFrame(ChannelHandlerContext ctx, WebSocketFrame frame) Handles the WebSocket frame and sends a response back to the server, if necessaryvoidHandles the handshake complete eventstatic EventSubinstance()Singleton instance getter.static StringThe default moderator user idvoidonClose()Handles the channel closing for any reason.voidRestarts EventSub when the API OAuth is re-authorized manuallystatic ZonedDateTimeParses a date from an EventSub message into aZonedDateTimevoidRestarts the EventSub connectionvoidRefreshes the internal list of existing subscriptionsReturns the WebSocket session IDvoidshutdown()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:WsClientFrameHandlerHandles the WebSocket frame and sends a response back to the server, if necessary- Specified by:
handleFramein interfaceWsClientFrameHandler- Parameters:
ctx- TheChannelHandlerContextof the sessionframe- TheWebSocketFrameto process
-
handshakeComplete
Description copied from interface:WsClientFrameHandlerHandles the handshake complete event- Specified by:
handshakeCompletein interfaceWsClientFrameHandler- Parameters:
ctx- TheChannelHandlerContextof the session
-
onClose
public void onClose()Description copied from interface:WsClientFrameHandlerHandles the channel closing for any reason.- Specified by:
onClosein interfaceWsClientFrameHandler
-
shutdown
public void shutdown()Shuts down EventSub
-