Example usage for io.netty.channel DefaultAddressedEnvelope content

List of usage examples for io.netty.channel DefaultAddressedEnvelope content

Introduction

In this page you can find the example usage for io.netty.channel DefaultAddressedEnvelope content.

Prototype

@Override
    public M content() 

Source Link

Usage

From source file:org.restcomm.media.control.mgcp.network.netty.MgcpMessageEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, DefaultAddressedEnvelope<MgcpMessage, SocketAddress> msg,
        List<Object> out) throws Exception {
    final InetSocketAddress sender = (InetSocketAddress) msg.sender();
    final InetSocketAddress recipient = (InetSocketAddress) msg.recipient();
    final byte[] content = msg.content().toString().getBytes();
    final ByteBuf buffer = Unpooled.buffer(content.length).writeBytes(content);
    final DatagramPacket packet = new DatagramPacket(buffer, recipient, sender);

    if (log.isDebugEnabled()) {
        log.debug("Sending outgoing message to " + recipient.getHostString() + "\n" + msg.toString());
    }/*from  w  ww  .j ava2s .  com*/

    out.add(packet);
}