Example usage for io.netty.channel.embedded EmbeddedChannel isRegistered

List of usage examples for io.netty.channel.embedded EmbeddedChannel isRegistered

Introduction

In this page you can find the example usage for io.netty.channel.embedded EmbeddedChannel isRegistered.

Prototype

@Override
    public boolean isRegistered() 

Source Link

Usage

From source file:net.epsilony.utils.codec.modbus.ModbusMasterCodecTest.java

License:Open Source License

@Test
public void test() throws InterruptedException, ExecutionException {
    SimpModbusMasterChannelInitializer init = new SimpModbusMasterChannelInitializer();
    EmbeddedChannel channel = new EmbeddedChannel(init);
    ChannelPromise newPromise = channel.newPromise();
    System.out.println(channel.isRegistered());

    ModbusClientMaster master = new ModbusClientMaster() {
        @Override/*ww  w . j  ava2 s  . c o m*/
        protected ChannelFuture genConnectFuture() {
            this.initializer = init;
            newPromise.setSuccess();
            return newPromise;
        }
    };

    CompletableFuture<ModbusResponse> future = master
            .request(new ModbusRequest(0, 0, MF.readRegisters(ModbusRegisterType.COIL, 0, 10)));
    future.get();
}