/// <param name="handlerEventLoopGroupFactory"></param> /// <param name="targetAddress">Ignored</param> /// <param name="targetPort">Ignored</param> /// <param name="certificate">Ignored</param> /// <returns></returns> public override async Task <IObservableChannel> BuildChannelAsync(IEventLoopGroupFactory handlerEventLoopGroupFactory, IPAddress targetAddress, int targetPort, X509Certificate2 certificate = null) { var channel = await BootStrapChannelAsync(handlerEventLoopGroupFactory, targetAddress, targetPort).ConfigureAwait(false); var messageStream = channel.Pipeline.Get <IObservableServiceHandler>()?.MessageStream; return(new ObservableChannel(messageStream ?? Observable.Never <IObserverDto <ProtocolMessage> >(), channel)); }
/// <param name="eventLoopGroupFactory"></param> /// <param name="targetAddress">Ignored</param> /// <param name="targetPort">Ignored</param> /// <param name="certificate">Local TLS certificate</param> public override async Task <IObservableChannel> BuildChannel(IEventLoopGroupFactory eventLoopGroupFactory, IPAddress targetAddress, int targetPort, X509Certificate2 certificate = null) { var channel = await Bootstrap(eventLoopGroupFactory, targetAddress, targetPort, certificate); var messageStream = _observableServiceHandler.MessageStream; return(new ObservableChannel(messageStream ?? Observable.Never <IObserverDto <ProtocolMessage> >(), channel)); }
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)); }
public async Task Can_Dispose_All_Event_Loops() { _eventFactory = new TcpClientEventLoopGroupFactory(_eventLoopGroupFactoryConfiguration); IEventLoopGroup[] eventLoops = { _eventFactory.GetOrCreateHandlerWorkerEventLoopGroup(), _eventFactory.GetOrCreateSocketIoEventLoopGroup() }; _eventFactory.Dispose(); while (!eventLoops.All(x => x.IsShutdown)) { await Task.Delay(100).ConfigureAwait(false); } eventLoops.ToList().ForEach(eventLoop => eventLoop.IsShutdown.Should().BeTrue()); }
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)); }
protected async Task <IChannel> Bootstrap(IEventLoopGroupFactory handlerEventLoopGroupFactory, IPAddress targetAddress, int targetPort, X509Certificate2 certificate = null) { var channelHandler = new ClientChannelInitializerBase <ISocketChannel>(HandlerGenerationFunction, handlerEventLoopGroupFactory, targetAddress, certificate); return(await new Bootstrap() .Group(handlerEventLoopGroupFactory.GetOrCreateSocketIoEventLoopGroup()) .ChannelFactory(() => new TcpSocketChannel()) .Option(ChannelOption.SoBacklog, _backLogValue) .Handler(new LoggingHandler(LogLevel.DEBUG)) .Handler(channelHandler) .ConnectAsync(targetAddress, targetPort) .ConfigureAwait(false)); }
public void Can_Spawn_Correct_Amount_Of_Tcp_Client_Event_Loops() { _eventFactory = new TcpClientEventLoopGroupFactory(_eventLoopGroupFactoryConfiguration); AssertEventLoopSize(_eventFactory.GetOrCreateHandlerWorkerEventLoopGroup(), ExpectedTcpClientThreads); AssertEventLoopSize(_eventFactory.GetOrCreateSocketIoEventLoopGroup(), ExpectedDefaultEventLoopThreadCount); }
public TestTcpServer(ITcpServerChannelFactory tcpServerChannelFactory, ILogger logger, IEventLoopGroupFactory eventLoopGroupFactory) : base(tcpServerChannelFactory, logger, eventLoopGroupFactory) { Channel = Substitute.For <IChannel>(); }
public TestSocketBase(IChannelFactory channelFactory, ILogger logger, IEventLoopGroupFactory eventLoopGroupFactory) : base(channelFactory, logger, eventLoopGroupFactory) { Channel = Substitute.For <IChannel>(); }
public abstract Task <IObservableChannel> BuildChannelAsync(IEventLoopGroupFactory eventLoopGroupFactory, IPAddress targetAddress, int targetPort, X509Certificate2 certificate = null);
protected TcpServer(ITcpServerChannelFactory tcpChannelFactory, ILogger logger, IEventLoopGroupFactory eventLoopGroupFactory) : base(tcpChannelFactory, logger, eventLoopGroupFactory) { }
protected ClientBase(IChannelFactory channelFactory, ILogger logger, IEventLoopGroupFactory handlerEventEventLoopGroupFactory) : base(channelFactory, logger, handlerEventEventLoopGroupFactory) { }
protected SocketBase(IChannelFactory channelFactory, ILogger logger, IEventLoopGroupFactory eventLoopGroupFactory) { ChannelFactory = channelFactory; _logger = logger; EventLoopGroupFactory = eventLoopGroupFactory; }
/// <inheritdoc /> internal ServerChannelInitializerBase(Func <IList <IChannelHandler> > handlerGenerationFunction, IEventLoopGroupFactory eventLoopGroupFactory, X509Certificate certificate = null) : base(handlerGenerationFunction, eventLoopGroupFactory, certificate: certificate) { }