Ejemplo n.º 1
0
        private async void TryConnect()
        {
            Text            = "Connecting...";
            status_lbl.Text = "Connecting...";
            await Task.Delay(1000);

            IronPythonScript.setup();
            string connected = IronPythonScript.connect(name, PIN);
            var    data      = JsonConvert.DeserializeObject <Dictionary <string, string> >(connected);

            if (data["status"] == "ok")
            {
                Text            = "Kalut Game";
                status_lbl.Text = "Connected! Please wait for the host to start the game...";
                GameStarted     = true;
                UID             = int.Parse(data["UID"]);
                await LoadQuiz();

                var worker = WaitForServerResponse();
                await worker.ContinueWith(t =>
                {
                    if (!t.Result.Keys.Contains("ShowQ"))
                    {
                        IronPythonScript.close(); parent.Show(); Close();
                    }
                    DisplayQuestion(int.Parse(t.Result["ShowQ"]));
                    status_lbl.Text = "Please wait...";
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
            else
            {
                Text            = "Kalut Client";
                status_lbl.Text = "Not connected!";
                DisplayJoinKalutView(true);
                joinview.err_lbl.Text = data["status"];
            }
        }
 private void back_btn_Click(object sender, EventArgs e)
 {
     parent.Show();
     Hide();
 }