use of io.netty.channel.DefaultAddressedEnvelope in project camel by apache.
the class DatagramPacketByteArrayEncoder method encode.
@Override
protected void encode(ChannelHandlerContext ctx, AddressedEnvelope<Object, InetSocketAddress> msg, List<Object> out) throws Exception {
if (msg.content() instanceof byte[]) {
delegateEncoder.encode(ctx, (byte[]) msg.content(), out);
ByteBuf buf = (ByteBuf) out.remove(out.size() - 1);
AddressedEnvelope<Object, InetSocketAddress> addressedEnvelop = new DefaultAddressedEnvelope<Object, InetSocketAddress>(buf.retain(), msg.recipient(), msg.sender());
out.add(addressedEnvelop);
}
}
use of io.netty.channel.DefaultAddressedEnvelope in project camel by apache.
the class DatagramPacketDelimiterDecoder method decode.
@Override
protected void decode(ChannelHandlerContext ctx, AddressedEnvelope<Object, InetSocketAddress> msg, List<Object> out) throws Exception {
if (msg.content() instanceof ByteBuf) {
ByteBuf payload = (ByteBuf) msg.content();
Object result = delegateDecoder.decode(ctx, payload);
AddressedEnvelope<Object, InetSocketAddress> addressEvelop = new DefaultAddressedEnvelope<Object, InetSocketAddress>(result, msg.recipient(), msg.sender());
out.add(addressEvelop);
}
}
Aggregations