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
An abstract processor of TMI messages
- Author:
- gmt2001
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe IRC commands this processor listens toprotected Flow.SubscriptionThe flow subscription -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor.protectedAbstractTMIProcessor(String command) Constructor.protectedAbstractTMIProcessor(String[] commands) Constructor.protectedAbstractTMIProcessor(List<String> commands) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected Stringchannel()Shortcut to get the channel nameprotected voidonClose()Default handler for TMIMessageType.CLOSE, no-opfinal voidSets this.subscription to null, then calls onFlowCompletefinal voidSends the stack trace to the logger, then calls onFlowErrorprotected voidOverride this method to handle Flow.Subscriber.OnComplete, called after this.subscription is set to nullprotected voidonFlowError(Throwable throwable) Override this method to handle Flow.Subscriber.OnError, called after the stack trace is sent to the loggerprotected voidonFlowNext(TMIMessage item) Override this method to handle Flow.Subscriber.OnNext, called after the default handlers for TMIMessageTypeprotected voidOverride this method to handle Flow.Subscriber.OnSubscribe, called after this.subscription is setprotected abstract voidonMessage(TMIMessage item) Called when a TMIMessage of type TMIMessageType.MESSAGE is receivedfinal voidonNext(TMIMessage item) Calls the default handlers by message type, then calls onFlowNextprotected voidonOpen()Default handler for TMIMessageType.OPEN, no-opfinal voidonSubscribe(Flow.Subscription subscription) Saves the subscription to this.subscription, then calls onFlowSubscribeprotected CaselessPropertiesShortcut to get the instance ofCaselessPropertiesprotected StringShortcut toCaselessProperties.getProperty(java.lang.String)protected TwitchSessionsession()Shortcut to get the instance ofTwitchSessionprotected final voidSubscribes to the Flow.Publisher of TwitchMessageInterfaceprotected TwitchMessageInterfacetmi()Shortcut to get the instance ofTwitchMessageInterfaceprotected Stringuser()Shortcut to get the bot username
-
Field Details
-
subscription
The flow subscription -
commands
The IRC commands this processor listens to
-
-
Constructor Details
-
AbstractTMIProcessor
protected AbstractTMIProcessor()Constructor. Subscribes to the Flow.Publisher and all IRC commands -
AbstractTMIProcessor
Constructor. Subscribes to the Flow.Publisher and a specified IRC command- Parameters:
command- The command to subscribe to
-
AbstractTMIProcessor
Constructor. Subscribes to the Flow.Publisher and the specified IRC commands- Parameters:
commands- The commands to subscribe to
-
AbstractTMIProcessor
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
Saves the subscription to this.subscription, then calls onFlowSubscribe- Specified by:
onSubscribein interfaceFlow.Subscriber<TMIMessage>- Parameters:
subscription-
-
onNext
Calls the default handlers by message type, then calls onFlowNext- Specified by:
onNextin interfaceFlow.Subscriber<TMIMessage>- Parameters:
item-
-
onError
Sends the stack trace to the logger, then calls onFlowError- Specified by:
onErrorin interfaceFlow.Subscriber<TMIMessage>- Parameters:
throwable-
-
onComplete
public final void onComplete()Sets this.subscription to null, then calls onFlowComplete- Specified by:
onCompletein interfaceFlow.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
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
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
Called when a TMIMessage of type TMIMessageType.MESSAGE is received- Parameters:
item- TheTMIMessagethat was received
-
properties
Shortcut to get the instance ofCaselessProperties- Returns:
-
property
Shortcut toCaselessProperties.getProperty(java.lang.String)- Parameters:
key-- Returns:
-
tmi
Shortcut to get the instance ofTwitchMessageInterface- Returns:
-
session
Shortcut to get the instance ofTwitchSession- Returns:
-
user
Shortcut to get the bot username- Returns:
-
channel
Shortcut to get the channel name- Returns:
-