Beispiel #1
0
        public void CanConnectToPiper_Messages()
        {
            var pipeOptions = new PipeOptions {
                Port = 22222
            };

            using (var pipeListener = new TcpListenerPiper(pipeOptions, CancellationToken.None))
            {
                var outgoingPipe = new OutgoingPipe(new NodeConnectionInfo
                {
                    Host = "localhost",
                    Port = pipeOptions.Port
                }, CancellationToken.None, new PipeOptions(), pipeListener);

                for (int i = 0; i < 10; i++)
                {
                    outgoingPipe.Write(new MyMsg {
                        i = i
                    });
                }

                for (int i = 0; i < 10; i++)
                {
                    var read = pipeListener.Read(CancellationToken.None).Result;
                    Assert.Equal(i, ((MyMsg)read.Item1).i);
                }
            }
        }
Beispiel #2
0
        public void Join(NodeConnectionInfo dest)
        {
            var destPipe = new OutgoingPipe(dest, _cancellationTokenSource.Token, _options, _tcpListenerPiper);

            _tempConnections.TryAdd(destPipe, dest);
            destPipe.Write(new JoinMessage
            {
                SenderInfo = _senderInfo
            });
        }
Beispiel #3
0
        public void CanConnectToPiper()
        {
            var pipeOptions = new PipeOptions();

            using (var pipeListener = new TcpListenerPiper(pipeOptions, CancellationToken.None))
            {
                var outgoingPipe = new OutgoingPipe(new NodeConnectionInfo
                {
                    Host = "localhost",
                    Port = pipeOptions.Port
                }, CancellationToken.None, new PipeOptions(), pipeListener);

                outgoingPipe.Write("hello there");

                var read = pipeListener.Read(CancellationToken.None).Result;
                Assert.Equal("hello there", read.Item1);
            }
        }