Top Description Fields Constructors Methods
io.netty5.handler.codec

public Class DatagramPacketDecoder

extends MessageToMessageDecoder<DatagramPacket>
Class Inheritance
Imports
io.netty5.buffer.Buffer, io.netty5.channel.ChannelHandlerContext, .ChannelPipeline, io.netty5.channel.socket.DatagramPacket, io.netty5.handler.codec.bytes.ByteArrayDecoder

A decoder that decodes the content of the received DatagramPacket using the specified Buffer decoder. E.g.,

ChannelPipeline pipeline = ...;
pipeline.addLast("udpDecoder", new DatagramPacketDecoder(new ByteArrayDecoder(...));

Field Summary

Modifier and TypeField and Description
private final MessageToMessageDecoder<Buffer>

Constructor Summary

AccessConstructor and Description
public
DatagramPacketDecoder(MessageToMessageDecoder<Buffer>
the specified Buffer decoder
decoder
)

Create a DatagramPacket decoder using the specified Buffer decoder.

Method Summary

Modifier and TypeMethod and Description
public boolean
acceptInboundMessage(Object msg)

Overrides io.netty5.handler.codec.MessageToMessageDecoder.acceptInboundMessage.

Returns true if the given message should be handled.
public void
public void
channelExceptionCaught(ChannelHandlerContext ctx, Throwable cause)

Overrides default io.netty5.channel.ChannelHandler.channelExceptionCaught.

Gets called if a Throwable was thrown when handling inbound events.
public void
channelInactive(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.channelInactive.

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.
public void
channelInboundEvent(ChannelHandlerContext ctx, Object evt)

Overrides default io.netty5.channel.ChannelHandler.channelInboundEvent.

Gets called if a custom inbound event happened.
public void
channelReadComplete(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.channelReadComplete.

Invoked when the last message read by the current read operation has been consumed by channelRead(ChannelHandlerContext, Object).
public void
public void
public void
channelWritabilityChanged(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.channelWritabilityChanged.

Gets called once the writable state of a Channel changed.
protected void
decode(ChannelHandlerContext ctx, DatagramPacket
the message to decode to another one
msg
)

Overrides io.netty5.handler.codec.MessageToMessageDecoder.decode.

Decode from one message to another.
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
public void
handlerRemoved(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.
public boolean
isSharable()

Overrides default io.netty5.channel.ChannelHandler.isSharable.

Returns true if this handler is sharable and thus can be added to more than one ChannelPipeline.
Inherited from io.netty5.handler.codec.MessageToMessageDecoder:
channelReaddecodeAndClose

Field Detail

decoderback to summary
private final MessageToMessageDecoder<Buffer> decoder

Constructor Detail

DatagramPacketDecoderback to summary
public DatagramPacketDecoder(MessageToMessageDecoder<Buffer> decoder)

Create a DatagramPacket decoder using the specified Buffer decoder.

Parameters
decoder:MessageToMessageDecoder<Buffer>

the specified Buffer decoder

Method Detail

acceptInboundMessageback to summary
public boolean acceptInboundMessage(Object msg) throws Exception

Overrides io.netty5.handler.codec.MessageToMessageDecoder.acceptInboundMessage.

Doc from io.netty5.handler.codec.MessageToMessageDecoder.acceptInboundMessage.

Returns true if the given message should be handled. If false it will be passed to the next ChannelHandler in the ChannelPipeline.

Annotations
@Override
channelActiveback to summary
public void channelActive(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelActive.

Doc from io.netty5.channel.ChannelHandler.channelActive.

The Channel of the ChannelHandlerContext is now active

Annotations
@Override
channelExceptionCaughtback to summary
public void channelExceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelExceptionCaught.

Doc from io.netty5.channel.ChannelHandler.channelExceptionCaught.

Gets called if a Throwable was thrown when handling inbound events.

Annotations
@Override
channelInactiveback to summary
public void channelInactive(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelInactive.

Doc from io.netty5.channel.ChannelHandler.channelInactive.

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.

Annotations
@Override
channelInboundEventback to summary
public void channelInboundEvent(ChannelHandlerContext ctx, Object evt) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelInboundEvent.

Doc from io.netty5.channel.ChannelHandler.channelInboundEvent.

Gets called if a custom inbound event happened.

Annotations
@Override
channelReadCompleteback to summary
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelReadComplete.

Doc from io.netty5.channel.ChannelHandler.channelReadComplete.

Invoked when the last message read by the current read operation has been consumed by channelRead(ChannelHandlerContext, Object). If ChannelOption#AUTO_READ is off, no further attempt to read an inbound data from the current Channel will be made until ChannelOutboundInvoker#read(ReadBufferAllocator) is called.

Annotations
@Override
channelRegisteredback to summary
public void channelRegistered(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelRegistered.

Doc from io.netty5.channel.ChannelHandler.channelRegistered.

The Channel of the ChannelHandlerContext was registered with its EventLoop

Annotations
@Override
channelUnregisteredback to summary
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelUnregistered.

Doc from io.netty5.channel.ChannelHandler.channelUnregistered.

The Channel of the ChannelHandlerContext was unregistered from its EventLoop

Annotations
@Override
channelWritabilityChangedback to summary
public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelWritabilityChanged.

Doc from io.netty5.channel.ChannelHandler.channelWritabilityChanged.

Gets called once the writable state of a Channel changed. You can check the state with Channel#writableBytes() or Channel#isWritable().

Annotations
@Override
decodeback to summary
protected void decode(ChannelHandlerContext ctx, DatagramPacket msg) throws Exception

Overrides io.netty5.handler.codec.MessageToMessageDecoder.decode.

Doc from io.netty5.handler.codec.MessageToMessageDecoder.decode.

Decode from one message to another. This method will be called for each written message that can be handled by this decoder.

The message will be disposed of after this call.

Subclasses that wish to sometimes pass messages through, should instead override the decodeAndClose(ChannelHandlerContext, Object) method.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToMessageDecoder belongs to

msg:DatagramPacket

the message to decode to another one

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs
handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Doc from io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
handlerRemovedback to summary
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Doc from io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
isSharableback to summary
public boolean isSharable()

Overrides default io.netty5.channel.ChannelHandler.isSharable.

Doc from io.netty5.channel.ChannelHandler.isSharable.

Returns true if this handler is sharable and thus can be added to more than one ChannelPipeline. By default, this method returns false. If this method returns false, you have to create a new handler instance every time you add it to a pipeline because it has unshared state such as member variables.

Annotations
@Override