Class DatagramPacketDecoder
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.handler.codec.MessageToMessageDecoder<DatagramPacket>
io.netty.handler.codec.DatagramPacketDecoder
- All Implemented Interfaces:
ChannelHandler, ChannelInboundHandler
A decoder that decodes the content of the received
DatagramPacket using
the specified ByteBuf decoder. E.g.,
ChannelPipeline pipeline = ...;
pipeline.addLast("udpDecoder", new DatagramPacketDecoder(new ProtobufDecoder(...));
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChannelHandler
ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif the given message should be handled.voidCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline.voidCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline.protected voiddecode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) Decode from one message to an other.voidexceptionCaught(ChannelHandlerContext ctx, Throwable cause) CallsChannelHandlerContext.fireExceptionCaught(Throwable)to forward to the nextChannelHandlerin theChannelPipeline.voidDo nothing by default, sub-classes may override this method.voidDo nothing by default, sub-classes may override this method.booleanReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.voiduserEventTriggered(ChannelHandlerContext ctx, Object evt) CallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline.Methods inherited from class MessageToMessageDecoder
channelReadMethods inherited from class ChannelHandlerAdapter
ensureNotSharable
-
Constructor Details
-
DatagramPacketDecoder
Create aDatagramPacketdecoder using the specifiedByteBufdecoder.- Parameters:
decoder- the specifiedByteBufdecoder
-
-
Method Details
-
acceptInboundMessage
Description copied from class:MessageToMessageDecoderReturnstrueif the given message should be handled. Iffalseit will be passed to the nextChannelInboundHandlerin theChannelPipeline.- Overrides:
acceptInboundMessagein classMessageToMessageDecoder<DatagramPacket>- Throws:
Exception
-
decode
protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception Description 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<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
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelRegistered()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelRegisteredin interfaceChannelInboundHandler- Overrides:
channelRegisteredin classChannelInboundHandlerAdapter- Throws:
Exception
-
channelUnregistered
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelUnregistered()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelUnregisteredin interfaceChannelInboundHandler- Overrides:
channelUnregisteredin classChannelInboundHandlerAdapter- Throws:
Exception
-
channelActive
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelActive()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelActivein interfaceChannelInboundHandler- Overrides:
channelActivein classChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelInactive()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelInactivein interfaceChannelInboundHandler- Overrides:
channelInactivein classChannelInboundHandlerAdapter- Throws:
Exception
-
channelReadComplete
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelReadComplete()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelReadCompletein interfaceChannelInboundHandler- Overrides:
channelReadCompletein classMessageToMessageDecoder<DatagramPacket>- Throws:
Exception
-
userEventTriggered
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireUserEventTriggered(Object)to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
userEventTriggeredin interfaceChannelInboundHandler- Overrides:
userEventTriggeredin classChannelInboundHandlerAdapter- Throws:
Exception
-
channelWritabilityChanged
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireChannelWritabilityChanged()to forward to the nextChannelInboundHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
channelWritabilityChangedin interfaceChannelInboundHandler- Overrides:
channelWritabilityChangedin classChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
Description copied from class:ChannelInboundHandlerAdapterCallsChannelHandlerContext.fireExceptionCaught(Throwable)to forward to the nextChannelHandlerin theChannelPipeline. Sub-classes may override this method to change behavior.- Specified by:
exceptionCaughtin interfaceChannelHandler- Specified by:
exceptionCaughtin interfaceChannelInboundHandler- Overrides:
exceptionCaughtin classChannelInboundHandlerAdapter- Throws:
Exception
-
handlerAdded
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerAddedin interfaceChannelHandler- Overrides:
handlerAddedin classChannelHandlerAdapter- Throws:
Exception
-
handlerRemoved
Description copied from class:ChannelHandlerAdapterDo nothing by default, sub-classes may override this method.- Specified by:
handlerRemovedin interfaceChannelHandler- Overrides:
handlerRemovedin classChannelHandlerAdapter- Throws:
Exception
-
isSharable
public boolean isSharable()Description copied from class:ChannelHandlerAdapterReturntrueif the implementation isChannelHandler.Sharableand so can be added to differentChannelPipelines.- Overrides:
isSharablein classChannelHandlerAdapter
-