Example usage for io.netty.channel EventLoopGroup register

List of usage examples for io.netty.channel EventLoopGroup register

Introduction

In this page you can find the example usage for io.netty.channel EventLoopGroup register.

Prototype

ChannelFuture register(ChannelPromise promise);

Source Link

Document

Register a Channel with this EventLoop using a ChannelFuture .

Usage

From source file:io.nodyn.tty.ReadStream.java

License:Apache License

public static ChannelFuture create(NodeProcess process, int fd, StreamWrap handle) throws IOException {
    if (fd == 0) {
        InputStream in = System.in;
        EventLoopGroup eventLoopGroup = process.getEventLoop().getEventLoopGroup();

        Channel channel = NioInputStreamChannel.create(process, in);
        channel.config().setAutoRead(false);
        channel.pipeline().addLast(new DataEventHandler(process, handle));
        eventLoopGroup.register(channel);

        return channel.newSucceededFuture();
    }/*from  w  w  w.j  a v  a 2s .  c  o m*/

    return null;
}

From source file:io.nodyn.tty.WriteStream.java

License:Apache License

public static ChannelFuture create(NodeProcess process, int fd, StreamWrap handle) throws IOException {
    OutputStream out = null;//from w  ww . j a  v  a2 s .c om
    if (fd == 1) {
        out = System.out;
    } else if (fd == 2) {
        out = System.err;
    } else {
        return null;
    }

    EventLoopGroup eventLoopGroup = process.getEventLoop().getEventLoopGroup();
    Channel channel = NioOutputStreamChannel.create(process, out);
    channel.config().setAutoRead(false);
    channel.pipeline().addLast(new DataEventHandler(process, handle));
    eventLoopGroup.register(channel);

    return channel.newSucceededFuture();
}