Package io.netty.handler.codec
Class DatagramPacketDecoder
- java.lang.Object
-
- io.netty.channel.ChannelHandlerAdapter
-
- io.netty.channel.ChannelInboundHandlerAdapter
-
- io.netty.handler.codec.MessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>
-
- io.netty.handler.codec.DatagramPacketDecoder
-
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler
public class DatagramPacketDecoder extends MessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>
A decoder that decodes the content of the receivedDatagramPacketusing the specifiedByteBufdecoder. E.g.,ChannelPipelinepipeline = ...; pipeline.addLast("udpDecoder", newDatagramPacketDecoder(newProtobufDecoder(...));
-
-
Constructor Summary
Constructors Constructor Description DatagramPacketDecoder(MessageToMessageDecoder<io.netty.buffer.ByteBuf> decoder)Create aDatagramPacketdecoder using the specifiedByteBufdecoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptInboundMessage(Object msg)Returnstrueif the given message should be handled.voidchannelActive(io.netty.channel.ChannelHandlerContext ctx)voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx)voidchannelReadComplete(io.netty.channel.ChannelHandlerContext ctx)voidchannelRegistered(io.netty.channel.ChannelHandlerContext ctx)voidchannelUnregistered(io.netty.channel.ChannelHandlerContext ctx)voidchannelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx)protected voiddecode(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.socket.DatagramPacket msg, List<Object> out)Decode from one message to an other.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)voidhandlerAdded(io.netty.channel.ChannelHandlerContext ctx)voidhandlerRemoved(io.netty.channel.ChannelHandlerContext ctx)booleanisSharable()voiduserEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt)-
Methods inherited from class io.netty.handler.codec.MessageToMessageDecoder
channelRead
-
-
-
-
Constructor Detail
-
DatagramPacketDecoder
public DatagramPacketDecoder(MessageToMessageDecoder<io.netty.buffer.ByteBuf> decoder)
Create aDatagramPacketdecoder using the specifiedByteBufdecoder.- Parameters:
decoder- the specifiedByteBufdecoder
-
-
Method Detail
-
acceptInboundMessage
public boolean acceptInboundMessage(Object msg) throws Exception
Description copied from class:MessageToMessageDecoderReturnstrueif the given message should be handled. Iffalseit will be passed to the nextChannelInboundHandlerin theChannelPipeline.- Overrides:
acceptInboundMessagein classMessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>- Throws:
Exception
-
decode
protected void decode(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.socket.DatagramPacket msg, List<Object> out) throws ExceptionDescription copied from class:MessageToMessageDecoderDecode from one message to an other. This method will be called for each written message that can be handled by this decoder.- Specified by:
decodein classMessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>- Parameters:
ctx- theChannelHandlerContextwhich thisMessageToMessageDecoderbelongs tomsg- the message to decode to an other oneout- theListto which decoded messages should be added- Throws:
Exception- is thrown if an error occurs
-
channelRegistered
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelRegisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelRegisteredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelUnregistered
public void channelUnregistered(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelUnregisteredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelUnregisteredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelReadComplete
public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelReadCompletein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelReadCompletein classMessageToMessageDecoder<io.netty.channel.socket.DatagramPacket>- Throws:
Exception
-
userEventTriggered
public void userEventTriggered(io.netty.channel.ChannelHandlerContext ctx, Object evt) throws Exception- Specified by:
userEventTriggeredin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
userEventTriggeredin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
channelWritabilityChangedin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelWritabilityChangedin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
handlerAddedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerAddedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) throws Exception- Specified by:
handlerRemovedin interfaceio.netty.channel.ChannelHandler- Overrides:
handlerRemovedin classio.netty.channel.ChannelHandlerAdapter- Throws:
Exception
-
isSharable
public boolean isSharable()
- Overrides:
isSharablein classio.netty.channel.ChannelHandlerAdapter
-
-