Example usage for io.netty.channel DefaultAddressedEnvelope recipient

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

Introduction

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

Prototype

A recipient

To view the source code for io.netty.channel DefaultAddressedEnvelope recipient.

Click 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   www  .  j  a  va  2  s . c  o  m*/

    out.add(packet);
}