Package com.manning.nettyinaction.chapter6

Source Code of com.manning.nettyinaction.chapter6.EventsViaChannelOutboundInvoker

package com.manning.nettyinaction.chapter6;

import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline;
import io.netty.util.CharsetUtil;

/**
*
* Listing 6.2, 6.3 and 6.4 of <i>Netty in Action</i>
*
* @author <a href="mailto:nmaurer@redhat.com">Norman Maurer</a>
*/
public class EventsViaChannelOutboundInvoker {

    /**
     *
     * Listing 6.2 of <i>Netty in Action</i>
     */
    public static void eventsViaChannel(ChannelHandlerContext context) {
        ChannelHandlerContext ctx = context;
        Channel channel = ctx.channel();
        channel.write(Unpooled.copiedBuffer("Netty in Action",
                CharsetUtil.UTF_8));

    }

    /**
     *
     * Listing 6.3 of <i>Netty in Action</i>
     */
    public static void eventsViaChannelPipeline(ChannelHandlerContext context) {
        ChannelHandlerContext ctx = context;
        ChannelPipeline pipeline = ctx.pipeline();
        pipeline.write(Unpooled.copiedBuffer("Netty in Action",
                CharsetUtil.UTF_8));

    }

    /**
     *
     * Listing 6.4 of <i>Netty in Action</i>
     */
    public static void eventsViaChannelHandlerContext(ChannelHandlerContext context) {
        ChannelHandlerContext ctx = context;
        ctx.write(Unpooled.copiedBuffer("Netty in Action",
                CharsetUtil.UTF_8));

    }
}
TOP

Related Classes of com.manning.nettyinaction.chapter6.EventsViaChannelOutboundInvoker

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.