use of org.apache.plc4x.java.tools.plc4xserver.protocol.Plc4xServerAdapter in project plc4x by apache.
the class Plc4xServer method start.
public void start() throws PlcException {
if (loopGroup != null) {
return;
}
try {
loopGroup = new NioEventLoopGroup();
workerGroup = new NioEventLoopGroup();
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(loopGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
@Override
public void initChannel(SocketChannel channel) {
ChannelPipeline pipeline = channel.pipeline();
pipeline.addLast(new GeneratedProtocolMessageCodec<>(Plc4xMessage.class, Plc4xMessage::staticParse, ByteOrder.BIG_ENDIAN, null, new ByteLengthEstimator(), null));
pipeline.addLast(new Plc4xServerAdapter());
}
}).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true);
bootstrap.bind(Plc4xConstants.PLC4XTCPDEFAULTPORT).sync();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new PlcException(e);
}
}
Aggregations