Class EventSubSubscriptionType

java.lang.Object
com.gmt2001.twitch.eventsub.EventSubSubscriptionType
All Implemented Interfaces:
Flow.Subscriber<EventSubInternalEvent>
Direct Known Subclasses:
AutomodMessage, ChannelFollow, ChannelModerate, ChannelPointsCustomRewardRedemptionAdd, ChannelUpdate, PredictionBegin, PredictionEnd, PredictionLock, PredictionProgress, Revocation, StreamOffline, StreamOnline, Test

public abstract class EventSubSubscriptionType extends Object implements Flow.Subscriber<EventSubInternalEvent>
Abstract base class for EventSub Subscription Types
Author:
gmt2001
  • Field Details

  • Constructor Details

    • EventSubSubscriptionType

      protected EventSubSubscriptionType()
    • EventSubSubscriptionType

      protected EventSubSubscriptionType(EventSubSubscription subscription, String messageId, ZonedDateTime messageTimestamp)
  • Method Details

    • subscribe

      protected final void subscribe()
    • onSubscribe

      public final void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<EventSubInternalEvent>
    • onNext

      public final void onNext(EventSubInternalEvent item)
      Specified by:
      onNext in interface Flow.Subscriber<EventSubInternalEvent>
    • onError

      public final void onError(Throwable throwable)
      Specified by:
      onError in interface Flow.Subscriber<EventSubInternalEvent>
    • onComplete

      public final void onComplete()
      Specified by:
      onComplete in interface Flow.Subscriber<EventSubInternalEvent>
    • onEventSubInternalEvent

      protected void onEventSubInternalEvent(EventSubInternalEvent e)
    • onEventSubInternalNotificationEvent

      protected void onEventSubInternalNotificationEvent(EventSubInternalNotificationEvent e)
    • onEventSubInternalRevocationEvent

      protected void onEventSubInternalRevocationEvent(EventSubInternalRevocationEvent e)
    • onEventSubInternalVerificationEvent

      protected void onEventSubInternalVerificationEvent(EventSubInternalVerificationEvent e)
    • create

      public Mono<EventSubSubscription> create()
      Creates a new EventSub subscription, using the parameters provided via other methods or the constructor. If a matching subscription already exists, it is returned instead
      Returns:
    • delete

      public Mono<Void> delete()
      Deletes the EventSub subscription matching the parameters in this object, if it can be found in the subscription list
      Returns:
    • deleteAll

      public List<Mono<Void>> deleteAll()
      Deletes all EventSub subscriptions matching the parameters in this object, if it can be found in the subscription list
      Returns:
    • proposeSubscription

      protected abstract EventSubSubscription proposeSubscription()
      Compiles the parameters of this object into an EventSubSubscription that can be created
      Returns:
    • proposeSubscriptionInternal

      protected EventSubSubscription proposeSubscriptionInternal(String type, String version, Map<String,String> condition)
      Actually creates the proposed EventSubSubscription
      Parameters:
      type - The subscription type to create
      version - The subscription type version
      condition - The conditions which will trigger notifications for this subscription
      Returns:
    • proposeTransport

      protected EventSubTransport proposeTransport()
      Creates a transport for a proposed subscription
      Returns:
    • validateParameters

      protected abstract void validateParameters() throws IllegalArgumentException
      Validates that the provided parameters are acceptable for use in proposeSubscription()
      Throws:
      IllegalArgumentException - One of the parameters is not acceptable
    • isAlreadySubscribed

      public boolean isAlreadySubscribed()
      Returns true if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states
      Returns:
    • getExistingSubscription

      public EventSubSubscription getExistingSubscription()
      Returns the existing subscription, if one already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states
      Returns:
    • findMatchingSubscriptionId

      public String findMatchingSubscriptionId()
      Returns the subscription id if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise null
      Returns:
    • findMatchingSubscriptionIds

      public List<String> findMatchingSubscriptionIds()
      Returns all subscription ids if a subscription already exists in either the ENABLED or WEBHOOK_CALLBACK_VERIFICATION_PENDING states, otherwise an empty list
      Returns:
    • isMatch

      protected abstract boolean isMatch(EventSubSubscription subscription)
      Returns true if the provided subscription is an instance of the current subscription type and matches the current subscription conditions
      Parameters:
      subscription -
      Returns:
    • subscription

      public EventSubSubscription subscription()
      Gets the subscription information, if the object was created as part of a notification
      Returns:
    • messageId

      public String messageId()
      Gets the message id, if the object was created as part of a notification
      Returns:
    • messageTimestamp

      public ZonedDateTime messageTimestamp()
      Gets the message timestamp, if the object was created as part of a notification
      Returns: