Esempio n. 1
0
        public async Task GetRandomQuestion(string oppositeUserConnectionId)
        {
            var randomQuestion = SignalRQuestionManager.GetRandomPictureQuestion();
            await Clients.Caller.SendAsync("GetRandomQuestion", randomQuestion);

            await Clients.Client(oppositeUserConnectionId).SendAsync("GetRandomQuestion", randomQuestion);
        }
Esempio n. 2
0
        public async Task CheckAnswer(byte questionId, string answer)
        {
            var claims = Context.User.Claims;
            var userId = Convert.ToInt64(claims.FirstOrDefault(x => x.Type == "userId").Value);

            var answerResult = SignalRQuestionManager.CheckPictureQuestionAnsver(questionId, answer);

            if (answerResult)
            {
                await Clients.Client(SignalRMatchingManager.GetOppositeUserConnection(userId)).SendAsync("oppositeKnewTheQuestion", true);

                await Clients.Caller.SendAsync("checkAnswer", true);

                return;
            }

            await Clients.Caller.SendAsync("checkAnswer", false);
        }