use of org.apache.plc4x.java.spi.connection.GeneratedProtocolMessageCodec in project plc4x by apache.
the class S7ServerModule method start.
@Override
public void start() throws SimulatorExcepiton {
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<>(TPKTPacket.class, TPKTPacket::staticParse, ByteOrder.BIG_ENDIAN, null, new S7Driver.ByteLengthEstimator(), new S7Driver.CorruptPackageCleaner()));
pipeline.addLast(new S7Step7ServerAdapter(context));
}
}).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true);
bootstrap.bind(ISO_ON_TCP_PORT).sync();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new SimulatorExcepiton(e);
}
}
use of org.apache.plc4x.java.spi.connection.GeneratedProtocolMessageCodec 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