Search in sources :

Example 1 with OpcServerHttpChannelInitializer

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;
}
Also used : ChannelOption(io.netty.channel.ChannelOption) LoggingHandler(io.netty.handler.logging.LoggingHandler) Multiset(com.google.common.collect.Multiset) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) EndpointConfiguration(org.eclipse.milo.opcua.stack.server.EndpointConfiguration) Stack(org.eclipse.milo.opcua.stack.core.Stack) Unit(org.eclipse.milo.opcua.stack.core.util.Unit) Map(java.util.Map) ChannelFutureListener(io.netty.channel.ChannelFutureListener) UaStackServer(org.eclipse.milo.opcua.stack.server.UaStackServer) SocketChannel(io.netty.channel.socket.SocketChannel) TransportProfile(org.eclipse.milo.opcua.stack.core.transport.TransportProfile) Logger(org.slf4j.Logger) ChannelInitializer(io.netty.channel.ChannelInitializer) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) PooledByteBufAllocator(io.netty.buffer.PooledByteBufAllocator) InetSocketAddress(java.net.InetSocketAddress) Maps(com.google.common.collect.Maps) OpcServerHttpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer) Channel(io.netty.channel.Channel) AsyncSemaphore(org.eclipse.milo.opcua.stack.core.util.AsyncSemaphore) ConcurrentHashMultiset(com.google.common.collect.ConcurrentHashMultiset) OpcServerTcpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.tcp.OpcServerTcpChannelInitializer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) LoggingHandler(io.netty.handler.logging.LoggingHandler) CompletableFuture(java.util.concurrent.CompletableFuture) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) OpcServerHttpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.http.OpcServerHttpChannelInitializer) OpcServerTcpChannelInitializer(org.eclipse.milo.opcua.stack.server.transport.tcp.OpcServerTcpChannelInitializer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Aggregations

ConcurrentHashMultiset (com.google.common.collect.ConcurrentHashMultiset)1 Maps (com.google.common.collect.Maps)1 Multiset (com.google.common.collect.Multiset)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 PooledByteBufAllocator (io.netty.buffer.PooledByteBufAllocator)1 Channel (io.netty.channel.Channel)1 ChannelFutureListener (io.netty.channel.ChannelFutureListener)1 ChannelInitializer (io.netty.channel.ChannelInitializer)1 ChannelOption (io.netty.channel.ChannelOption)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 LoggingHandler (io.netty.handler.logging.LoggingHandler)1 InetSocketAddress (java.net.InetSocketAddress)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Stack (org.eclipse.milo.opcua.stack.core.Stack)1 TransportProfile (org.eclipse.milo.opcua.stack.core.transport.TransportProfile)1 AsyncSemaphore (org.eclipse.milo.opcua.stack.core.util.AsyncSemaphore)1 Unit (org.eclipse.milo.opcua.stack.core.util.Unit)1 EndpointConfiguration (org.eclipse.milo.opcua.stack.server.EndpointConfiguration)1