示例#1
0
        public async Task ConnectedEvent_HasRightRemoteEndpointDetails()
        {
            EpoxyTransport transport = MakeTransport();
            var            listener  = transport.MakeListener(localhostEndpoint);

            EpoxyConnection remoteConnection   = null;
            var             connectedEventDone = new ManualResetEventSlim(initialState: false);

            listener.Connected += (sender, args) =>
            {
                Assert.AreSame(listener, sender);
                remoteConnection = (EpoxyConnection)args.Connection;
                connectedEventDone.Set();
            };

            await listener.StartAsync();

            var connection = await transport.ConnectToAsync(listener.ListenEndpoint);

            bool wasSignaled = connectedEventDone.Wait(TimeSpan.FromSeconds(30));

            Assert.IsTrue(wasSignaled, "Timed out waiting for Connected event to complete");

            Assert.AreEqual(connection.LocalEndPoint, remoteConnection.RemoteEndPoint);
            Assert.AreEqual(connection.RemoteEndPoint, remoteConnection.LocalEndPoint);

            await transport.StopAsync();
        }
示例#2
0
        public async Task OneConnectionStalledDuringHandshake_CanAcceptAnother()
        {
            EpoxyTransport transport = MakeTransport();

            listener = transport.MakeListener(localhostEndpoint);
            await listener.StartAsync();

            var noHandshakeConnection = new TcpClient();
            // This will just establish a TCP connection. It won't perform the Epoxy handshake, so
            // the listener will just be sitting there waiting for the client to send some data.
            await noHandshakeConnection.ConnectAsync(localhostEndpoint.Address, localhostEndpoint.Port);

            var  connectTask = transport.ConnectToAsync(localhostAddress);
            bool didConnect  = connectTask.Wait(TimeSpan.FromSeconds(10));

            Assert.IsTrue(didConnect, "Timed out waiting for connection to be established.");

            await transport.StopAsync();
        }
示例#3
0
 private static void Shutdown(EpoxyTransport transport)
 {
     Task.WaitAll(transport.StopAsync(), pingConnection.StopAsync(), reverseConnection.StopAsync());
 }
示例#4
0
 private static void Shutdown(EpoxyTransport transport)
 {
     Task.WaitAll(transport.StopAsync(), pingConnection.StopAsync(), reverseConnection.StopAsync());
 }