예제 #1
0
        public void ProcessAnswer(string information)
        {
            dynamic jsonData = JsonConvert.DeserializeObject(information);

            if (jsonData.id == "session/start")
            {
                sessionID = (String)jsonData.data.sessionID;
                System.Diagnostics.Debug.WriteLine("sessionID: " + sessionID);
                getData = new Thread(GetData);
                getData.Start();
                Thread.Sleep(2000);
                simulation?.s.startSession();
            }
            if (jsonData.id == "session/end")
            {
                System.Diagnostics.Debug.WriteLine("Closing...");
                isConnected = false;
                close();
            }
            if (jsonData.id == "log in")
            {
                if (jsonData.data.status != "ok")
                {
                    new Thread(() => { MessageBox.Show("Username or password is incorrect"); }).Start();
                    close();
                }
                else
                {
                    vrc = new VRConnector2();
                    new Thread(() => { MessageBox.Show("You are now connected, please put on VR glasses on now"); }).Start();
                }
            }
            if (jsonData.id == "client/message")
            {
                HandleNewMessageFromDoctor((string)jsonData.data.message);
            }
            if (jsonData.id == "client/SetPower")
            {
                ergometerCOM?.SetPower((int)jsonData.data.power);
                simulation?.SetPower((int)jsonData.data.power);
            }
        }
예제 #2
0
 public void SetPower(int power)
 {
     ergometerCOM?.SetPower(power);
     simulation?.SetPower(power);
 }