- java.lang.Object
-
- io.netty5.channel.SimpleUserEventChannelHandler<I>
-
- All Implemented Interfaces:
ChannelHandler
public abstract class SimpleUserEventChannelHandler<I> extends Object implements ChannelHandler
ChannelHandler
which allows to conveniently only handle a specific type of user events. For example, here is an implementation which only handleString
user events.public class StringEventHandler extends
Be aware that depending of the constructor parameters it will release all handled events by passing them toSimpleUserEventChannelHandler
<String
> {@Override
protected void eventReceived(ChannelHandlerContext
ctx,String
evt) throwsException
{ System.out.println(evt); } }Resource.dispose(Object)
.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SimpleUserEventChannelHandler()
seeSimpleUserEventChannelHandler(boolean)
withtrue
as boolean parameter.protected
SimpleUserEventChannelHandler(boolean autoRelease)
Create a new instance which will try to detect the types to match out of the type parameter of the class.protected
SimpleUserEventChannelHandler(Class<? extends I> eventType)
seeSimpleUserEventChannelHandler(Class, boolean)
withtrue
as boolean value.protected
SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease)
Create a new instance
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
acceptEvent(Object evt)
Returnstrue
if the given user event should be handled.void
channelInboundEvent(ChannelHandlerContext ctx, Object evt)
Gets called if a custom inbound event happened.protected abstract void
eventReceived(ChannelHandlerContext ctx, I evt)
Is called for each user event triggered of typeSimpleUserEventChannelHandler
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.netty5.channel.ChannelHandler
bind, channelActive, channelExceptionCaught, channelInactive, channelRead, channelReadComplete, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
-
-
-
Constructor Detail
-
SimpleUserEventChannelHandler
protected SimpleUserEventChannelHandler()
seeSimpleUserEventChannelHandler(boolean)
withtrue
as boolean parameter.
-
SimpleUserEventChannelHandler
protected SimpleUserEventChannelHandler(boolean autoRelease)
Create a new instance which will try to detect the types to match out of the type parameter of the class.- Parameters:
autoRelease
-true
if handled events should be released automatically by passing them toResource.dispose(Object)
.
-
SimpleUserEventChannelHandler
protected SimpleUserEventChannelHandler(Class<? extends I> eventType)
seeSimpleUserEventChannelHandler(Class, boolean)
withtrue
as boolean value.
-
SimpleUserEventChannelHandler
protected SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease)
Create a new instance- Parameters:
eventType
- The type of events to matchautoRelease
-true
if handled events should be released automatically by passing them toResource.dispose(Object)
.
-
-
Method Detail
-
acceptEvent
protected boolean acceptEvent(Object evt) throws Exception
Returnstrue
if the given user event should be handled. Iffalse
it will be passed to the nextChannelHandler
in theChannelPipeline
.- Throws:
Exception
-
channelInboundEvent
public final void channelInboundEvent(ChannelHandlerContext ctx, Object evt) throws Exception
Description copied from interface:ChannelHandler
Gets called if a custom inbound event happened.- Specified by:
channelInboundEvent
in interfaceChannelHandler
- Throws:
Exception
-
eventReceived
protected abstract void eventReceived(ChannelHandlerContext ctx, I evt) throws Exception
Is called for each user event triggered of typeSimpleUserEventChannelHandler
.- Parameters:
ctx
- theChannelHandlerContext
which thisSimpleUserEventChannelHandler
belongs toevt
- the user event to handle- Throws:
Exception
- is thrown if an error occurred
-
-