コード例 #1
0
        public async Task <IActionResult> StartASession([FromBody] StartSessionRequest request)
        {
            Guid lobbyId = playerRegistry.GetLobbyIdByPlayerId(request.PlayerId);

            List <ServerSidePlayerOverview> players = playerRegistry.GetAllPlayersInLobby(request.PlayerId);

            StartSessionResponse response = new StartSessionResponse
            {
                Players   = players,
                SessionId = lobbyId,                              //shortcut
                Questions = new List <ServerSideQuestionOverview> //shortcuts
                {
                    new ServerSideQuestionOverview {
                        Text = "What number is NOT a Fibonacci number", Options = new List <String> {
                            "1", "2", "8", "20"
                        }, CorrectOptionIndex = 3, Value = 1000,
                    },
                    new ServerSideQuestionOverview {
                        Text = "What was the name of the supernatural computer in »The hitchhiker's guide to the galaxy«", Options = new List <String> {
                            "Who cares", "Think deep", "Deep Thought", "42"
                        }, CorrectOptionIndex = 2, Value = 2000,
                    },
                    new ServerSideQuestionOverview {
                        Text = "According to Scott Pilgrim, how many vegan law violations can you commit without losing your vegan superpowers?", Options = new List <String> {
                            "4", "3", "2", "1"
                        }, CorrectOptionIndex = 1, Value = 3000,
                    },
                    new ServerSideQuestionOverview {
                        Text = "You know what? (F is for Familiy)", Options = new List <String> {
                            "You know what?", "You know what? You know what?", "You know what? You know what? You know what? ", "You know what? You know what? You know what? You know what?"
                        }, CorrectOptionIndex = 1, Value = 4000,
                    },
                }
            };

            await lobbyHubContext.Clients.Group(lobbyId.ToString()).StartSession(response);

            return(base.NoContent());
        }