コード例 #1
0
        protected async Task <IChannel> BootStrapChannelAsync(IEventLoopGroupFactory handlerEventLoopGroupFactory,
                                                              IPAddress address,
                                                              int port)
        {
            var channelHandler = new ServerChannelInitializerBase <IChannel>(HandlerGenerationFunction, handlerEventLoopGroupFactory);

            return(await new Bootstrap()
                   .Group(handlerEventLoopGroupFactory.GetOrCreateSocketIoEventLoopGroup())
                   .ChannelFactory(() => new SocketDatagramChannel(AddressFamily.InterNetwork))
                   .Option(ChannelOption.SoBroadcast, true)
                   .Handler(new LoggingHandler(LogLevel.DEBUG))
                   .Handler(channelHandler)
                   .BindAsync(address, port)
                   .ConfigureAwait(false));
        }
コード例 #2
0
        protected async Task <IChannel> BootstrapAsync(IEventLoopGroupFactory handlerEventLoopGroupFactory,
                                                       IPAddress targetAddress,
                                                       int targetPort,
                                                       X509Certificate2 certificate)
        {
            var supervisorLoopGroup = ((ITcpServerEventLoopGroupFactory)handlerEventLoopGroupFactory)
                                      .GetOrCreateSupervisorEventLoopGroup();
            var channelHandler = new ServerChannelInitializerBase <IChannel>(HandlerGenerationFunction, handlerEventLoopGroupFactory, certificate);

            return(await new ServerBootstrap()
                   .Group(handlerEventLoopGroupFactory.GetOrCreateSocketIoEventLoopGroup(), supervisorLoopGroup)
                   .ChannelFactory(() => new TcpServerSocketChannel())
                   .Option(ChannelOption.SoBacklog, _backLogValue)
                   .Handler(new LoggingHandler(LogLevel.DEBUG))
                   .ChildHandler(channelHandler)
                   .BindAsync(targetAddress, targetPort)
                   .ConfigureAwait(false));
        }