Пример #1
0
        /// <summary>
        /// Inform the clients to reveal the votes.
        /// </summary>
        /// <returns>A task representing the request.</returns>
        public async Task SendResult(SendResultRequest request)
        {
            _logger.LogDebug($"Enter {nameof(SendResult)}");

            var player = dataStore2.GetPlayerState(PlayerID);

            if (!player.IsModerator)
            {
                _logger.LogError($"Player '{PlayerID}' tried to perform a moderator-only action.");
                return;
            }

            var gamePhase = dataStore2.GetGamePhase(Room);

            if (gamePhase != GamePhase.Voting)
            {
                _logger.LogError($"Player '{PlayerID}' requested vote results during a non-voting phase of play.");
                return;
            }

            var sendResultResponse = CreateSendResultResponse();

            dataStore2.SetGamePhase(Room, GamePhase.Results);
            await Clients
            .Group(Room)
            .SendAsync("StartDiscussionPhase", sendResultResponse);

            _logger.LogDebug($"Exit {nameof(SendResult)}");
        }
 public async Task SendResult(SendResultRequest request)
 => await Clients.User(request.UserId).Result(request.Result);