StopClient() public method

public StopClient ( ) : void
return void
        public async Task TestLargeSizeMessage()
        {
            _testService = new TestServer(_port);
            Assert.AreEqual(true, _testService.StartService());

            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            Assert.AreEqual(true, clientConnected);

            const int length = 100000;
            var charArray = new char[length];
            charArray[0] = 'a';
            for (int i = 1; i < length-1; ++i) charArray[i] = 'b';
            charArray[length-1] = 'c';
            var testString = new string(charArray);

            // how to set a timeout? 

            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            _testServiceClient.StopClient();
            // assert client is stopped?
            _testService.StopService();
        }
Esempio n. 2
0
        private async void TestConnectionButton_OnClick(object sender, RoutedEventArgs e)
        {
            InfoLabel.Text = "Running...";
            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            InfoLabel.Text = clientConnected ? "Pass" : "Fail";

            _testServiceClient.StopClient();
        }
Esempio n. 3
0
        private async void TestLargeSizeMessageButton_OnClick(object sender, RoutedEventArgs e)
        {
            InfoLabel.Text = "Running...";
            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();

            const int length = 30000;
            var charArray = new char[length];
            charArray[0] = 'a';
            for (int i = 1; i < length - 1; ++i) charArray[i] = 'b';
            charArray[length - 1] = 'c';
            var testString = new string(charArray);

            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;

            if (response != null && response.Message.Equals(TestServiceConstants.ServicePrefix + testString))
                InfoLabel.Text = "Pass";
            else
                InfoLabel.Text = "Fail";
            _testServiceClient.StopClient();
        }
        public async Task TestWebSocketOODSSService()
        {
            _testService = new TestServer(_port);
            Assert.AreEqual(true, _testService.StartService());

            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            Assert.AreEqual(true, clientConnected);

            const string testString = "Hello world!";
            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            Assert.IsNotNull(response);
            Assert.AreEqual(TestServiceConstants.ServicePrefix + testString, response.Message);

            _testServiceClient.StopClient();
            // assert client is stopped?
            _testService.StopService();
        }
Esempio n. 5
0
        private async void TestReconnectionButton_OnClick(object sender, RoutedEventArgs e)
        {
            InfoLabel.Text = "Running...";
            _testServiceClient = new TestServiceClient(_serverAddress, _port);
            bool clientConnected = await _testServiceClient.StartConnection();
            if (!clientConnected)
            {
                InfoLabel.Text = "Fail";
                return;
            }
            var testString = "Hello world!";
            var response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;
            _testServiceClient.StopClient();

            clientConnected = await _testServiceClient.StartConnection();
            if (!clientConnected)
            {
                InfoLabel.Text = "Fail";
                return;
            }
            response = (await _testServiceClient.SendMessage(testString)) as TestServiceResponse;

            if (response != null && response.Message.Equals(TestServiceConstants.ServicePrefix + testString))
                InfoLabel.Text = "Pass";
            else
                InfoLabel.Text = "Fail";

            _testServiceClient.StopClient();
        }