Beispiel #1
0
        private void GetQuestionFromServer()
        {
            string questionJSON = string.Empty;

            questionJSON = dictSockets[Lobby.SUB_QUESTION].GetMessage();

            //string questionText;
            //QuestionWithAnswers qwa = new QuestionWithAnswers(questionJSON);
            QA question = LitJson.JsonMapper.ToObject <QA>(questionJSON);

            if (question.answers.Count <= 1)
            {
                Invoke(new Action(() => {
                    UpdateQuestionText(question.question.text);
                    btnEnterAnswer.Enabled = true;
                    HideAnswerButtons();
                }));
            }
            else
            {
                Invoke(new Action(() => {
                    answers = question.getAllAnswersAsStrings();
                    InstantiateAnswerButtons(answers);
                }));
            }

            // Question now has only the question:
            //question = qwa.QuestionString;

            // Received answers from question:
            //answers = question.wrongAnswers.ToList();

            // Update question text:


            // Ako je poslato pitanje sa unesenim odgovorima:
            // '#' je escape simbol za prvo slanje pitanja.

            /*if (!answers[0].Equals("#"))
             *  // Instantiate answers:
             *  InstantiateAnswerButtons(answers);
             * else {
             *  // U suprotnom treba da se samo pitanje postavi
             *  // i ugase dugmici.
             *  HideAnswerButtons();
             * }*/
        }