public async Task <TestClientServer <TService> > SetupTestClientServer <TService>( ILayerStackProvider serviceLayerStackProvider = null, ILayerStackProvider clientLayerStackProvider = null ) where TService : class, IService, new() { var testService = new TService(); EpoxyTransport serviceTransport = new EpoxyTransportBuilder() .SetLayerStackProvider(serviceLayerStackProvider) .Construct(); listener = serviceTransport.MakeListener(new IPEndPoint(IPAddress.Loopback, EpoxyTransport.DefaultInsecurePort)); listener.AddService(testService); await listener.StartAsync(); EpoxyTransport clientTransport = new EpoxyTransportBuilder() .SetLayerStackProvider(clientLayerStackProvider) .Construct(); EpoxyConnection clientConnection = await clientTransport.ConnectToAsync("epoxy://127.0.0.1"); return(new TestClientServer <TService> { Service = testService, ServiceTransport = serviceTransport, Listener = listener, ClientConnection = clientConnection, ClientTransport = clientTransport }); }
public static async Task <TestClientServer <TService> > SetupTestClientServer <TService>(ILayerStack serviceLayerStack = null, ILayerStack clientLayerStack = null) where TService : class, IService, new() { var testService = new TService(); EpoxyTransport serviceTransport = new EpoxyTransportBuilder() .SetLayerStack(serviceLayerStack) .Construct(); EpoxyListener listener = serviceTransport.MakeListener(new IPEndPoint(IPAddress.Loopback, 0)); listener.AddService(testService); await listener.StartAsync(); EpoxyTransport clientTransport = new EpoxyTransportBuilder() // some tests rely on the use of DebugExceptionHandler to assert things about the error message .SetLayerStack(clientLayerStack) .Construct(); EpoxyConnection clientConnection = await clientTransport.ConnectToAsync(listener.ListenEndpoint); return(new TestClientServer <TService> { Service = testService, ServiceTransport = serviceTransport, Listener = listener, ClientConnection = clientConnection, ClientTransport = clientTransport }); }
private async static Task <EpoxyTransport> SetupAsync() { var transport = new EpoxyTransportBuilder() .SetLogSink(new ConsoleLogger()) .Construct(); var pingPongService = new PingPongService(); EpoxyListener pingPongListener = transport.MakeListener(PingEndpoint); pingPongListener.AddService(pingPongService); var reversePingPongService = new ReversePingPongService(); EpoxyListener reversePingPongListener = transport.MakeListener(ReversePingEndpoint); reversePingPongListener.AddService(reversePingPongService); await Task.WhenAll( pingPongListener.StartAsync(), reversePingPongListener.StartAsync()); pingConnection = await transport.ConnectToAsync(PingUri); reverseConnection = await transport.ConnectToAsync(ReversePingUri); return(transport); }
private async static Task <EpoxyTransport> SetupAsync() { var transport = new EpoxyTransportBuilder() .SetLogSink(new ConsoleLogger()) .SetMetricsSink(new ConsoleMetricsSink()) .Construct(); var pingEndpoint = new IPEndPoint(IPAddress.Loopback, pingPort); var reversePingEndpoint = new IPEndPoint(IPAddress.Loopback, reversePingPort); var pingPongService = new PingPongService(); EpoxyListener pingPongListener = transport.MakeListener(pingEndpoint); pingPongListener.AddService(pingPongService); var reversePingPongService = new ReversePingPongService(); EpoxyListener reversePingPongListener = transport.MakeListener(reversePingEndpoint); reversePingPongListener.AddService(reversePingPongService); await Task.WhenAll( pingPongListener.StartAsync(), reversePingPongListener.StartAsync()); s_pingConnection = await transport.ConnectToAsync(pingPongListener.ListenEndpoint, CancellationToken.None); s_reverseConnection = await transport.ConnectToAsync(reversePingPongListener.ListenEndpoint, CancellationToken.None); return(transport); }
private static async Task SetupAsync(ILayerStackProvider layerStackProvider) { var endpoint = new IPEndPoint(IPAddress.Loopback, (int)PingConstants.Port); EpoxyTransport transport = new EpoxyTransportBuilder().SetLayerStackProvider(layerStackProvider).Construct(); EpoxyListener pingPongListener = transport.MakeListener(endpoint); var pingPongService = new PingPongService(); pingPongListener.AddService(pingPongService); await pingPongListener.StartAsync(); }
static Task StartServiceListenersAsync(EpoxyTransport transport) { // On some systems, "localhost" resolves to an IPv4 address, while // on others it resolves to an IPv6 address. To make this work on // both kinds of systems, we create a listener for both loopback // addresses. var service = new SimpleService(); EpoxyListener listenerIpv4 = transport.MakeListener(serviceEndpointIpv4); listenerIpv4.AddService(service); EpoxyListener listenerIpv6 = transport.MakeListener(serviceEndpointIpv6); listenerIpv6.AddService(service); return(Task.WhenAll(listenerIpv4.StartAsync(), listenerIpv6.StartAsync())); }
static async Task MainAsync(X509Certificate2 serverCertificate) { var tlsConfig = new EpoxyServerTlsConfig(serverCertificate); EpoxyTransport transport = new EpoxyTransportBuilder().SetServerTlsConfig(tlsConfig).Construct(); EpoxyListener listener = transport.MakeListener(serviceEndpoint); listener.AddService(new SimpleService()); await listener.StartAsync(); var connection = await transport.ConnectToAsync("epoxys://localhost"); var proxy = new SimpleProxy <EpoxyConnection>(connection); IMessage <SimpleResult> response = await proxy.SimpleMethodAsync(); PrintResponse(response); }
private async static Task <EpoxyTransport> SetupAsync() { var transport = new EpoxyTransportBuilder() .SetLogSink(new ConsoleLogger()) .Construct(); var assignAPortEndPoint = new IPEndPoint(IPAddress.Loopback, EpoxyTransport.DefaultInsecurePort); var notifyService = new NotifyEventService(); EpoxyListener notifyListener = transport.MakeListener(assignAPortEndPoint); notifyListener.AddService(notifyService); await notifyListener.StartAsync(); s_connection = await transport.ConnectToAsync("epoxy://127.0.0.1", CancellationToken.None); return(transport); }
private async static Task <EpoxyTransport> SetupAsync() { var handler = new ConsoleLogger(); Log.SetHandler(handler); var transport = new EpoxyTransportBuilder().Construct(); var assignAPortEndPoint = new IPEndPoint(IPAddress.Loopback, 0); var notifyService = new NotifyEventService(); EpoxyListener notifyListener = transport.MakeListener(assignAPortEndPoint); notifyListener.AddService(notifyService); await notifyListener.StartAsync(); s_connection = await transport.ConnectToAsync(notifyListener.ListenEndpoint, CancellationToken.None); return(transport); }