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.Subscription
The flow subscription -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Constructor.protected
AbstractTMIProcessor
(String command) Constructor.protected
AbstractTMIProcessor
(String[] commands) Constructor.protected
AbstractTMIProcessor
(List<String> commands) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected String
channel()
Shortcut to get the channel nameprotected void
onClose()
Default handler for TMIMessageType.CLOSE, no-opfinal void
Sets this.subscription to null, then calls onFlowCompletefinal void
Sends the stack trace to the logger, then calls onFlowErrorprotected void
Override this method to handle Flow.Subscriber.OnComplete, called after this.subscription is set to nullprotected void
onFlowError
(Throwable throwable) Override this method to handle Flow.Subscriber.OnError, called after the stack trace is sent to the loggerprotected void
onFlowNext
(TMIMessage item) Override this method to handle Flow.Subscriber.OnNext, called after the default handlers for TMIMessageTypeprotected void
Override this method to handle Flow.Subscriber.OnSubscribe, called after this.subscription is setprotected abstract void
onMessage
(TMIMessage item) Called when a TMIMessage of type TMIMessageType.MESSAGE is receivedfinal void
onNext
(TMIMessage item) Calls the default handlers by message type, then calls onFlowNextprotected void
onOpen()
Default handler for TMIMessageType.OPEN, no-opfinal void
onSubscribe
(Flow.Subscription subscription) Saves the subscription to this.subscription, then calls onFlowSubscribeprotected CaselessProperties
Shortcut to get the instance ofCaselessProperties
protected String
Shortcut toCaselessProperties.getProperty(java.lang.String)
protected TwitchSession
session()
Shortcut to get the instance ofTwitchSession
protected final void
Subscribes to the Flow.Publisher of TwitchMessageInterfaceprotected TwitchMessageInterface
tmi()
Shortcut to get the instance ofTwitchMessageInterface
protected String
user()
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:
onSubscribe
in interfaceFlow.Subscriber<TMIMessage>
- Parameters:
subscription
-
-
onNext
Calls the default handlers by message type, then calls onFlowNext- Specified by:
onNext
in interfaceFlow.Subscriber<TMIMessage>
- Parameters:
item
-
-
onError
Sends the stack trace to the logger, then calls onFlowError- Specified by:
onError
in interfaceFlow.Subscriber<TMIMessage>
- Parameters:
throwable
-
-
onComplete
public final void onComplete()Sets this.subscription to null, then calls onFlowComplete- Specified by:
onComplete
in 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
- TheTMIMessage
that 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:
-