Class 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 Details

    • instance

      public static EventSub instance()
      Singleton instance getter.
      Returns:
    • moderatorUserId

      public static String moderatorUserId()
      The default moderator user id
      Returns:
    • debug

      public static boolean debug()
      Indicates if EventSub debug output is enabled
      Returns:
    • debug

      public static void debug(String message)
      Logs a debug message for EventSub
      Parameters:
      message - The message to log
    • debug

      public static void debug(String message, Throwable ex)
      Logs a debug message for EventSub
      Parameters:
      message - The message to log
      ex - The exception to log
    • subscriptions

      public Map<String,EventSubSubscription> subscriptions()
      Gets all current EventSub subscriptions
      Returns:
    • sessionId

      public String sessionId()
      Returns the WebSocket session ID
      Returns:
    • deleteSubscription

      public Mono<Void> deleteSubscription(String id)
      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

      public static ZonedDateTime parseDate(String date)
      Parses a date from an EventSub message into a ZonedDateTime
      Parameters:
      date - A date string to parse in RFC3339 format
      Returns:
    • onTwitchOAuthReauthorizedEvent

      public void onTwitchOAuthReauthorizedEvent(TwitchOAuthReauthorizedEvent event)
      Restarts EventSub when the API OAuth is re-authorized manually
      Parameters:
      event - The event object
    • reconnect

      public void reconnect()
      Restarts the EventSub connection
    • handleFrame

      public void handleFrame(ChannelHandlerContext ctx, WebSocketFrame frame)
      Description copied from interface: WsClientFrameHandler
      Handles the WebSocket frame and sends a response back to the server, if necessary
      Specified by:
      handleFrame in interface WsClientFrameHandler
      Parameters:
      ctx - The ChannelHandlerContext of the session
      frame - The WebSocketFrame to process
    • handshakeComplete

      public void handshakeComplete(ChannelHandlerContext ctx)
      Description copied from interface: WsClientFrameHandler
      Handles the handshake complete event
      Specified by:
      handshakeComplete in interface WsClientFrameHandler
      Parameters:
      ctx - The ChannelHandlerContext of the session
    • onClose

      public void onClose()
      Description copied from interface: WsClientFrameHandler
      Handles the channel closing for any reason.
      Specified by:
      onClose in interface WsClientFrameHandler
    • shutdown

      public void shutdown()
      Shuts down EventSub