AddressedEnvelope to DatagramPacket using
the specified message encoder. E.g.,
ChannelPipeline pipeline = ...;
pipeline.addLast("udpEncoder", new DatagramPacketEncoder(new ByteArrayEncoder(...));
Note: As UDP packets are out-of-order, you should make sure the encoded message size are not greater than
the max safe packet size in your particular network path which guarantees no packet fragmentation.
| Modifier and Type | Field and Description |
|---|---|
| private final MessageToMessageEncoder |
| Access | Constructor and Description |
|---|---|
| public | DatagramPacketEncoder(MessageToMessageEncoder<? super M>
the specified message encoder encoder)Create an encoder that encodes the content in |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | acceptOutboundMessage(Object msg)
Overrides io. true if the given message should be handled.
|
| public Future | bind(ChannelHandlerContext
the ctx, SocketAddress ChannelHandlerContext for which the bind operation is madethe localAddress)SocketAddress to which it should boundOverrides default io. |
| public Future | close(ChannelHandlerContext
the ctx)ChannelHandlerContext for which the close operation is madeOverrides default io. |
| public Future | connect(ChannelHandlerContext
the ctx, SocketAddress ChannelHandlerContext for which the connect operation is madethe remoteAddress, SocketAddress SocketAddress to which it should connectthe localAddress)SocketAddress which is used as source on connectOverrides default io. |
| public Future | deregister(ChannelHandlerContext
the ctx)ChannelHandlerContext for which the deregister operation is madeOverrides default io. EventLoop.
|
| public Future | disconnect(ChannelHandlerContext
the ctx)ChannelHandlerContext for which the disconnect operation is madeOverrides default io. |
| protected void | encode(ChannelHandlerContext
the ctx, AddressedEnvelope<M, InetSocketAddress> ChannelHandlerContext which this MessageToMessageEncoder belongs to.the message to encode to another one. msg, List<Object> the out)List into which produced output messages should be added.Overrides io. |
| public void | flush(ChannelHandlerContext
the ctx)ChannelHandlerContext for which the flush operation is madeOverrides default io. |
| public void | handlerAdded(ChannelHandlerContext ctx)
Overrides default io. ChannelHandler was added to the actual context and it's ready to handle events.
|
| public void | handlerRemoved(ChannelHandlerContext ctx)
Overrides default io. ChannelHandler was removed from the actual context and it doesn't handle events
anymore.
|
| public boolean | isSharable()
Overrides default io. true if this handler is sharable and thus can be added
to more than one ChannelPipeline.
|
| public void | read(ChannelHandlerContext
the ctx, ReadBufferAllocator ChannelHandlerContext for which the read operation is madeThe readBufferAllocator)ReadBufferAllocator that should be used to allocate a Buffer
if needed (for reading the data).Overrides default io. EventLoop.
|
| encoder | back to summary |
|---|---|
| private final MessageToMessageEncoder<? super M> encoder | |
| DatagramPacketEncoder | back to summary |
|---|---|
| public DatagramPacketEncoder(MessageToMessageEncoder<? super M> encoder) Create an encoder that encodes the content in
| |
| acceptOutboundMessage | back to summary |
|---|---|
| public boolean acceptOutboundMessage(Object msg) throws Exception Overrides io. Doc from io. Returns
| |
| bind | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a bind operation is made.
| |
| close | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a close operation is made.
| |
| connect | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a connect operation is made.
| |
| deregister | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a deregister operation is made from the current registered
| |
| disconnect | back to summary |
|---|---|
| public Future Overrides default io. Doc from io. Called once a disconnect operation is made.
| |
| encode | back to summary |
|---|---|
| protected void encode(ChannelHandlerContext ctx, AddressedEnvelope<M, InetSocketAddress> msg, List<Object> out) throws Exception Overrides io. Doc from io. 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
| |
| flush | back to summary |
|---|---|
| public void flush(ChannelHandlerContext ctx) Overrides default io. Doc from io. Called once a flush operation is made. The flush operation will try to flush out all previous written messages that are pending.
| |
| handlerAdded | back to summary |
|---|---|
| public void handlerAdded(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Gets called after the
| |
| handlerRemoved | back to summary |
|---|---|
| public void handlerRemoved(ChannelHandlerContext ctx) throws Exception Overrides default io. Doc from io. Gets called after the
| |
| isSharable | back to summary |
|---|---|
| public boolean isSharable() Overrides default io. Doc from io. Returns
| |
| read | back to summary |
|---|---|
| public void read(ChannelHandlerContext ctx, ReadBufferAllocator readBufferAllocator) Overrides default io. Doc from io. Called once a read operation is made from the current registered
| |