private void loginButton_Click(object sender, RoutedEventArgs e) { string email = emailText.Text; string password = passwordBox.Password; if (rememberCheckBox.IsChecked.Value) { //store the creds locally and then auto fill when this page is loaded try { settings["email"] = email; settings["password"] = password; settings["checkbox"] = rememberCheckBox.IsChecked.Value; } catch (KeyNotFoundException) { settings.Add("email", email); settings.Add("password", password); settings.Add("checkbox", rememberCheckBox.IsChecked.Value); } } CrackApi.login(email, password, doneLogin); loginProgress.Visibility = System.Windows.Visibility.Visible; }
void gameClicked(object sender, RoutedEventArgs e) { Game g = (Game)sender; game_id = g.id; CrackApi.games(user_id, session_id, game_id, gameCallback); }
void loginCallback(string result) { JObject jo = JObject.Parse(result); //Debug.WriteLine(jo.ToString()); session_id = jo["session"].Value <string>("session"); user_id = jo.Value <string>("id"); //got the session id and user id //now we need to load the active games CrackApi.dashboard(user_id, session_id, dashboardCallback); }
void gameCallback(string result) { JObject jo = JObject.Parse(result); //Debug.WriteLine(jo.ToString()); if (jo["game_status"].Value <string>() == "ENDED") { //we win go home InitializeComponent(); //reload active games CrackApi.dashboard(user_id, session_id, dashboardCallback); } else { Question q = new Question(jo, questionDone); this.Content = q; } }
void gotAnswer(string result) { //get next question CrackApi.games(user_id, session_id, game_id, gameCallback); }
void questionDone(JToken answer) { //send answer to server CrackApi.answer(user_id, session_id, game_id, answer, gotAnswer); }