Ejemplo n.º 1
0
        private async void ConnectToEmokitServer(bool tryAgain)
        {
            IStatus.Text = "Connecting to the server";
            try
            {
                var hubConnection = new HubConnection(StaticVariables.ServerURL);
                EmokitHub = hubConnection.CreateHubProxy(StaticVariables.EmokitHub);
                EmokitHub.On <string>("OnProducerChanged", OnProducerChanged);
                await hubConnection.Start(new LongPollingTransport());

                // start the emokit server
                IsServerConnected = true;
                IStatus.Text      = "Connected to the server";
                await Task.Delay(100);

                await EmokitHub.Invoke <bool>("Stop");

                if (tryAgain)
                {
                    StartPythonApp();
                }
            }
            catch (Exception)
            {
                IsServerConnected = false;
                IStatus.Text      = "Failed to connect";
                SetStage(InitialEmokit, LoadingPanel);
            }
        }
Ejemplo n.º 2
0
 private async void CButton_Click(object sender, RoutedEventArgs e)
 {
     SetStage(LoadingPanel, ControlEmokit);
     if ((string)CButton.Content == "Start")
     {
         await EmokitHub.Invoke <bool>("Start");
     }
     else
     {
         await EmokitHub.Invoke <bool>("Stop");
     }
 }
Ejemplo n.º 3
0
        private void OnProducerChanged(string value)
        {
            Application.Current.Dispatcher.Invoke(new Action(async() =>
            {
                await Task.Delay(2000);
                switch (value)
                {
                case "init":
                    if (IQuestion1.SelectedIndex == 2)
                    {
                        UpdateIQuestion2();
                        await EmokitHub.Invoke <bool>("Stop");
                    }
                    else
                    {
                        IStatus.Text = "";
                        CStatus.Text = "Please check the Python console if it received the 'init'";
                        SetStage(ControlEmokit, LoadingPanel);
                    }
                    break;

                case "start":
                    CButton.Content = "Stop";
                    CStatus.Text    = "Close the console after saving completes. 'Initialize' will start a new process while saving!!";
                    SetStage(ControlEmokit, LoadingPanel);
                    break;

                case "stop":
                    CButton.Content = "Start";
                    SetStage(InitialEmokit, LoadingPanel);
                    break;

                default:
                    break;
                }
            }));
        }