예제 #1
0
        public Client(ClientData clientdata, ErgometerSimulatie simulation, string comport)
        {
            this.simulation = simulation;
            bool ipIsOk = IPAddress.TryParse("127.0.0.1", out localhost);

            if (!ipIsOk)
            {
                Console.WriteLine("ip adres kan niet geparsed worden."); Environment.Exit(1);
            }

            client  = new TcpClient(localhost.ToString(), port);
            _stream = client.GetStream();
            if (_SSL)
            {
                _sslStream = new SslStream(_stream, false, new RemoteCertificateValidationCallback(ValidateCert));
                _sslStream.AuthenticateAsClient("Healthcare", null, System.Security.Authentication.SslProtocols.Tls12, false);
            }
            isConnected = true;
            if (comport != null)
            {
                ergometerCOM = new Healthcare_test.ErgometerCOM(comport, "9600");
            }

            read = new Thread(Read);
            read.Start();
            sendlogin(clientdata.username, clientdata.password);
        }
예제 #2
0
        private void sign_in_Btn_Click(object sender, EventArgs e)
        {
            ClientData currentClient = new ClientData(username.Text, password.Text);


            response.Text = "connected";

            if (ergometer != null)
            {
                ergometer.Close();
            }
            if (comportCombo.SelectedItem.ToString() == "Simulator")
            {
                ErgometerSimulatie ergometersimulatie = new ErgometerSimulatie();
                Client             client             = new Client(currentClient, ergometersimulatie, null);
            }
            else
            {
                string comPort = comportCombo.SelectedItem.ToString();
                Client client  = new Client(currentClient, null, comPort);
            }
        }