ChannelHandler which allows to explicit only handle a specific type of messages.
For example here is an implementation which only handle String messages.
public class StringHandler extends
SimpleChannelInboundHandler<String> {
@Override
protected void messageReceived(ChannelHandlerContext ctx, String message)
throws Exception {
System.out.println(message);
}
}
Be aware that depending of the constructor parameters it will release all handled messages by passing them to
Resource#dispose(Object).
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private final TypeParameterMatcher |
| Access | Constructor and Description |
|---|---|
| protected | SimpleChannelInboundHandler()
see |
| protected | SimpleChannelInboundHandler(boolean
true if handled messages should be released automatically by passing them to
Resource#dispose(Object).Create a new instance which will try to detect the types to match out of the type parameter of the class. |
| protected | SimpleChannelInboundHandler(Class<? extends I> inboundMessageType)
see |
| protected | SimpleChannelInboundHandler(Class<? extends I>
The type of messages to match inboundMessageType, boolean true if handled messages should be released automatically by passing them to
Resource#dispose(Object).Create a new instance |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public void | channelRead(ChannelHandlerContext ctx, Object msg)
Overrides default io. Channel has read a message from the peer.
|
| protected abstract void | messageReceived(ChannelHandlerContext
the ctx, I ChannelHandlerContext which this SimpleChannelInboundHandler
belongs tothe message to handle msg)Is called for each message of type |
| autoRelease | back to summary |
|---|---|
| private final boolean autoRelease | |
| matcher | back to summary |
|---|---|
| private final TypeParameterMatcher matcher | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler() see | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler(boolean autoRelease) Create a new instance which will try to detect the types to match out of the type parameter of the class.
| |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler(Class<? extends I> inboundMessageType) see | |
| SimpleChannelInboundHandler | back to summary |
|---|---|
| protected SimpleChannelInboundHandler(Class<? extends I> inboundMessageType, boolean autoRelease) Create a new instance
| |
| acceptInboundMessage | back to summary |
|---|---|
| public boolean acceptInboundMessage(Object msg) throws Exception Returns | |
| channelRead | back to summary |
|---|---|
| public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception Overrides default io. Doc from io. Invoked when the current
| |
| messageReceived | back to summary |
|---|---|
| protected abstract void messageReceived(ChannelHandlerContext ctx, I msg) throws Exception Is called for each message of type
| |