Exemplo n.º 1
0
 public void TearDown()
 {
     _client.Disconnect();
     _server.Stop();
     _client = null;
     _server = null;
 }
Exemplo n.º 2
0
        public void ClientSendDataConcurrent()
        {
            _forever        = true;
            _clientDataPass = true;
            Alchemy.Handlers.Handler.FastDirectSendingMode = false;
            _requestId      = 1000;
            _responseId     = 1000;
            _requestId2     = 2000;
            _responseId2    = 2000;
            _expectedLength = 8;
            var client2 = new WebSocketClient("ws://127.0.0.1:54321/path")
            {
                OnReceive = OnClientReceive2
            };

            if (_client.Connected)
            {
                client2.Connect();

                if (client2.Connected)
                {
                    _client.Send("Test1000");
                    client2.Send("Halo2000");
                }
                else
                {
                    _clientDataPass = false;
                }
                Thread.Sleep(5000);
            }
            else
            {
                _clientDataPass = false;
            }
            Assert.IsTrue(_clientDataPass);
            Assert.IsTrue(_requestId == _responseId || _requestId - 1 == _responseId);
            Assert.IsTrue(_requestId2 == _responseId2 || _requestId2 - 1 == _responseId2);
            Assert.IsTrue(_responseId > 1010);
            Assert.IsTrue(_responseId2 > 2010);

            _client.Disconnect();
            client2.Disconnect();
            Assert.IsFalse(_client.Connected);
            Assert.IsFalse(client2.Connected);

            _client.Connect();
            Assert.IsTrue(_client.Connected);
        }