private void parseMessage(string message)
        {
            try
            {
                if (message.IndexOf("{") > -1)
                {
                    message = message.Substring(message.IndexOf("{"));
                }

                SocketMessage json = JsonConvert.DeserializeObject <SocketMessage>(message);

                if (json.name == "log" && userid == null)
                {
                    userid = json.args[0].user;
                    Console.WriteLine("Got user id: " + userid);
                }


                string questionid = json.args[0].qid;
                string question   = json.args[0].question;
                string answer     = json.args[0].answer;
                double endtime    = json.args[0].end_time;

                QuestionEventArgs q = new QuestionEventArgs(questionid, question, answer, endtime);
                if (!q.Equals(lastq) && !q.isEmpty())
                {
                    lastq = q;
                    OnQuestionEvent?.Invoke(this, q);
                }
            }
            catch (Exception e) { }
        }
示例#2
0
    private void OnVideoObjectClicked(VideoObject sender)
    {
        if (_clicked)
        {
            return;
        }
        _clicked = true;

        int  answer      = Array.IndexOf(_videosObjects, sender);
        bool rightAnswer = answer == _goodAnswer;

        sender.Feedback(rightAnswer);

        if (!rightAnswer)
        {
            _videosObjects[_goodAnswer].Feedback(true);
        }

        DOVirtual.DelayedCall(1f, () => OnQuestionAnswered?.Invoke(answer, rightAnswer));
    }