Пример #1
0
        public void should_process_receive_completion_result()
        {
            try
            {
                // Arrange
                _processor.Start();

                var byteReceivedSignal   = new AutoResetEvent(false);
                var requestReceiveSignal = new AutoResetEvent(false);
                _sessionMock.Setup(x => x.OnBytesReceived(12, 8)).Callback(delegate { byteReceivedSignal.Set(); });
                _sessionMock.Setup(x => x.RequestReceive(12)).Callback(delegate { requestReceiveSignal.Set(); });

                // Act
                var results = new[]
                {
                    new RIO_RESULT
                    {
                        BytesTransferred      = 8,
                        ConnectionCorrelation = _sessionId,
                        RequestCorrelation    = 12
                    }
                };

                _testCompletionQueue.AvailableResults.Enqueue(results);

                // Assert
                Assert.IsTrue(byteReceivedSignal.WaitOne(TimeSpan.FromMilliseconds(100)));
                Assert.IsTrue(requestReceiveSignal.WaitOne(TimeSpan.FromMilliseconds(100)));
            }
            finally
            {
                _processor.Stop();
            }
        }
Пример #2
0
        public void Start(string peerId)
        {
            _receiveCompletionProcessor.Start();
            _requestProcessingEngine.Start();

            StartListening();
        }
Пример #3
0
        public void Start(string peerId)
        {
            if (IsConnected)
            {
                throw new InvalidOperationException("Already started");
            }

            CheckOnlyStartedOnce();

            _receiveCompletionProcessor.Start();
            _sendRequestProcessingEngine.Start();

            _socket = CreateSocket();

            _session.Open(_socket);

            Connect(_socket, _serverEndpoint);

            _session.InitiateReceiving();

            Handshake(peerId);

            IsConnected = true;
            Connected?.Invoke();
        }
Пример #4
0
        public void Start(string peerId)
        {
            if (IsRunning)
            {
                throw new InvalidOperationException("Already started");
            }

            CheckOnlyStartedOnce();

            _receiveCompletionProcessor.Start();
            _sendRequestProcessingEngine.Start();

            StartListening();

            IsRunning = true;
        }