/// <summary> /// Server refresh and check on every 10 seconds. Iterates through the database and adds and then deletes to update /// the instructors queue. /// </summary> /// <param name="sender"></param> Sender of the event /// <param name="e"></param> The event private async void ServerTimer_Tick(object sender, EventArgs e) { FirebaseResponse retrieveQuestions = await client.GetAsync("Question Information/" + _username); QuestionInformation quesData = retrieveQuestions.ResultAs <QuestionInformation>(); //Call a helper to get all of the student usernames and place each one in a queue if (quesData != null) { Stack <string> questions = GetQuestion(quesData.question); Stack <string> passQuestions = new Stack <string>(); if (_isInstructor) { while (questions.Count > 0) { if (questions.Peek() == string.Empty) { questions.Pop(); } else { queue.AddQuestion(passQuestions.Pop(), quesData.IP, quesData.username); } } uxQuestionCount.Text = "# of Questions: " + queue.Count.ToString(); FirebaseResponse delete = await client.DeleteAsync("Question Information/" + _username); } else if (!_isInstructor) { // queue = queue stored in the cloud } } //changes }
private Stack <string> GetQuestion(string username) { FirebaseResponse retrieve = client.Get("Question Information/" + username); QuestionInformation quesData = retrieve.ResultAs <QuestionInformation>(); Stack <string> userinfo = new Stack <string>(); userinfo.Push(quesData.question); return(userinfo); }
/// <summary> /// Click event for the submit button. Adds a new string to construct a new QuestionItem from the cloud. /// </summary> /// <param name="sender"></param> Sender of the event /// <param name="e"></param> The event private async void UxSubmit_Click(object sender, EventArgs e) { var questionInfo = new QuestionInformation { username = _username, question = uxInputQuestion.Text, IP = GetLocalIP(), Count = _count++ }; SetResponse queueInfo = await client.SetAsync("Question Information/" + questionInfo.question, questionInfo); uxChatBox.Text += ("-- QUESTION ADDED --\r\n"); }