Class AbstractTMIProcessor

java.lang.Object
com.gmt2001.twitch.tmi.processors.AbstractTMIProcessor
All Implemented Interfaces:
Flow.Subscriber<TMIMessage>
Direct Known Subclasses:
CapabilityTMIProcessor, ClearChatTMIProcessor, ClearMsgTMIProcessor, GlobalUserStateTMIProcessor, JoinTMIProcessor, NoticeTMIProcessor, Numeric001TMIProcessor, Numeric353TMIProcessor, PartTMIProcessor, PingTMIProcessor, PrivMsgTMIProcessor, ReconnectTMIProcessor, RoomStateTMIProcessor, UserNoticeTMIProcessor, UserStateTMIProcessor, WhisperTMIProcessor

public abstract class AbstractTMIProcessor extends Object implements Flow.Subscriber<TMIMessage>
An abstract processor of TMI messages
Author:
gmt2001
  • Field Details

    • subscription

      protected Flow.Subscription subscription
      The flow subscription
    • commands

      protected final List<String> commands
      The IRC commands this processor listens to
  • Constructor Details

    • AbstractTMIProcessor

      protected AbstractTMIProcessor()
      Constructor. Subscribes to the Flow.Publisher and all IRC commands
    • AbstractTMIProcessor

      protected AbstractTMIProcessor(String command)
      Constructor. Subscribes to the Flow.Publisher and a specified IRC command
      Parameters:
      command - The command to subscribe to
    • AbstractTMIProcessor

      protected AbstractTMIProcessor(String[] commands)
      Constructor. Subscribes to the Flow.Publisher and the specified IRC commands
      Parameters:
      commands - The commands to subscribe to
    • AbstractTMIProcessor

      protected AbstractTMIProcessor(List<String> commands)
      Constructor. Subscribes to the Flow.Publisher and the specified IRC commands
      Parameters:
      commands - The commands to subscribe to
  • Method Details

    • subscribe

      protected final void subscribe()
      Subscribes to the Flow.Publisher of TwitchMessageInterface
    • onSubscribe

      public final void onSubscribe(Flow.Subscription subscription)
      Saves the subscription to this.subscription, then calls onFlowSubscribe
      Specified by:
      onSubscribe in interface Flow.Subscriber<TMIMessage>
      Parameters:
      subscription -
    • onNext

      public final void onNext(TMIMessage item)
      Calls the default handlers by message type, then calls onFlowNext
      Specified by:
      onNext in interface Flow.Subscriber<TMIMessage>
      Parameters:
      item -
    • onError

      public final void onError(Throwable throwable)
      Sends the stack trace to the logger, then calls onFlowError
      Specified by:
      onError in interface Flow.Subscriber<TMIMessage>
      Parameters:
      throwable -
    • onComplete

      public final void onComplete()
      Sets this.subscription to null, then calls onFlowComplete
      Specified by:
      onComplete in interface Flow.Subscriber<TMIMessage>
    • onOpen

      protected void onOpen()
      Default handler for TMIMessageType.OPEN, no-op
    • onClose

      protected void onClose()
      Default handler for TMIMessageType.CLOSE, no-op
    • onFlowNext

      protected void onFlowNext(TMIMessage item)
      Override this method to handle Flow.Subscriber.OnNext, called after the default handlers for TMIMessageType
      Parameters:
      item - The TMIMessage that was submitted
    • onFlowSubscribe

      protected void onFlowSubscribe()
      Override this method to handle Flow.Subscriber.OnSubscribe, called after this.subscription is set
    • onFlowError

      protected void onFlowError(Throwable throwable)
      Override this method to handle Flow.Subscriber.OnError, called after the stack trace is sent to the logger
      Parameters:
      throwable - The throwable that is causing the subscription to be canceled
    • onFlowComplete

      protected void onFlowComplete()
      Override this method to handle Flow.Subscriber.OnComplete, called after this.subscription is set to null
    • onMessage

      protected abstract void onMessage(TMIMessage item)
      Called when a TMIMessage of type TMIMessageType.MESSAGE is received
      Parameters:
      item - The TMIMessage that was received
    • properties

      protected CaselessProperties properties()
      Shortcut to get the instance of CaselessProperties
      Returns:
    • property

      protected String property(String key)
      Parameters:
      key -
      Returns:
    • tmi

      protected TwitchMessageInterface tmi()
      Shortcut to get the instance of TwitchMessageInterface
      Returns:
    • session

      protected TwitchSession session()
      Shortcut to get the instance of TwitchSession
      Returns:
    • user

      protected String user()
      Shortcut to get the bot username
      Returns:
    • channel

      protected String channel()
      Shortcut to get the channel name
      Returns: