use of org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer in project milo by eclipse.
the class ServerChannelManager method bootstrap.
private static CompletableFuture<Channel> bootstrap(UaStackServer stackServer, InetSocketAddress bindAddress, TransportProfile transportProfile) {
ChannelInitializer<SocketChannel> initializer;
if (transportProfile == TransportProfile.TCP_UASC_UABINARY) {
initializer = new OpcServerTcpChannelInitializer(stackServer);
} else {
initializer = new OpcServerHttpChannelInitializer(stackServer);
}
ServerBootstrap bootstrap = new ServerBootstrap();
bootstrap.group(Stack.sharedEventLoop()).handler(new LoggingHandler(ServerChannelManager.class)).channel(NioServerSocketChannel.class).childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT).childOption(ChannelOption.TCP_NODELAY, true).childHandler(initializer);
CompletableFuture<Channel> channelFuture = new CompletableFuture<>();
bootstrap.bind(bindAddress).addListener((ChannelFutureListener) future -> {
if (future.isSuccess()) {
Channel channel = future.channel();
channelFuture.complete(channel);
} else {
channelFuture.completeExceptionally(future.cause());
}
});
return channelFuture;
}
Aggregations