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

public Class DatagramDnsResponseEncoder

extends MessageToMessageEncoder<AddressedEnvelope<DnsResponse, InetSocketAddress>>
Class Inheritance
Annotations
@UnstableApi
Imports
io.netty5.buffer.Buffer, io.netty5.channel.AddressedEnvelope, .ChannelHandlerContext, io.netty5.channel.socket.DatagramPacket, io.netty5.handler.codec.MessageToMessageEncoder, io.netty5.util.internal.UnstableApi, java.net.InetSocketAddress, java.util.List

Encodes a DatagramDnsResponse (or an AddressedEnvelope of DnsResponse} into a DatagramPacket.

Field Summary

Modifier and TypeField and Description
private final DnsRecordEncoder

Constructor Summary

AccessConstructor and Description
public
public
DatagramDnsResponseEncoder(DnsRecordEncoder recordEncoder)

Creates a new encoder with the specified recordEncoder.

Method Summary

Modifier and TypeMethod and Description
protected Buffer
allocateBuffer(ChannelHandlerContext ctx, AddressedEnvelope<DnsResponse, InetSocketAddress> msg)

Allocate a Buffer which will be used for constructing a datagram packet.

protected void
encode(ChannelHandlerContext ctx, AddressedEnvelope<DnsResponse, InetSocketAddress>
the message to encode to another one.
in
,
List<Object>
the List into which produced output messages should be added.
out
)

Overrides io.netty5.handler.codec.MessageToMessageEncoder.encode.

Encode from one message to another.
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.MessageToMessageEncoder:
acceptOutboundMessageencodeAndClosewrite

Field Detail

recordEncoderback to summary
private final DnsRecordEncoder recordEncoder

Constructor Detail

DatagramDnsResponseEncoderback to summary
public DatagramDnsResponseEncoder()

Creates a new encoder with the default record encoder.

DatagramDnsResponseEncoderback to summary
public DatagramDnsResponseEncoder(DnsRecordEncoder recordEncoder)

Creates a new encoder with the specified recordEncoder.

Method Detail

allocateBufferback to summary
protected Buffer allocateBuffer(ChannelHandlerContext ctx, AddressedEnvelope<DnsResponse, InetSocketAddress> msg) throws Exception

Allocate a Buffer which will be used for constructing a datagram packet. Sub-classes may override this method to return a Buffer with a perfect matching initial capacity.

encodeback to summary
protected void encode(ChannelHandlerContext ctx, AddressedEnvelope<DnsResponse, InetSocketAddress> in, List<Object> out) throws Exception

Overrides io.netty5.handler.codec.MessageToMessageEncoder.encode.

Doc from io.netty5.handler.codec.MessageToMessageEncoder.encode.

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

The message will be disposed of after this call.

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

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this MessageToMessageEncoder belongs to.

in:AddressedEnvelope<DnsResponse, InetSocketAddress>

the message to encode to another one.

out:List<Object>

the List into which produced output messages should be added.

Annotations
@Override
Exceptions
Exception:
is thrown if an error occurs.
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