示例#1
0
        public async Task <IActionResult> AddPlayer([FromBody] CreatePlayerRequest request)
        {
            PlayerServerSide player = new PlayerServerSide(request.Name, request.AvatarUrl, request.Id);

            playerRegistry.AddPlayer(request.Id, player);

            await lobbyHubContext.Clients.All.NewPlayer(new ServerSidePlayerOverview
            {
                AvatarUrl = request.AvatarUrl,
                Id        = request.Id,
                Name      = request.Name,
            });

            Guid lobbyId = playerRegistry.GetLobbyIdByPlayerId(request.Id);

            return(base.Ok(new AddPlayerResponse {
                LobbyId = lobbyId
            }));
        }