public static async Task <ResponseWrapper <SetMatchLobbyLockStateResponse> > Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient) { var context = await FunctionContext <SetMatchLobbyLockStateRequest> .Create(req); var matchLobbyId = context.FunctionArgument.MatchLobbyId; var locked = context.FunctionArgument.Locked; var creatorId = context.CallerEntityProfile.Entity.Id; try { var matchLobby = await MatchLobbyUtil.SetMatchLobbyLockState(matchLobbyId, locked, creatorId, cosmosDBClient); return(new ResponseWrapper <SetMatchLobbyLockStateResponse> { StatusCode = StatusCode.OK, Response = new SetMatchLobbyLockStateResponse { MatchLobby = matchLobby } }); } catch (TicTacToeException exception) { return(TicTacToeExceptionUtil.GetEmptyResponseWrapperFromException <SetMatchLobbyLockStateResponse>(exception)); } }
public static async Task <ResponseWrapper <JoinMatchLobbyResponse> > Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient) { var context = await FunctionContext <JoinMatchLobbyRequest> .Create(req); var matchLobbyId = context.FunctionArgument.MatchLobbyId; var invitationCode = context.FunctionArgument.InvitationCode; var playerTwo = context.CallerEntityProfile.Entity.Id; try { var matchLobby = await MatchLobbyUtil.JoinMatchLobby(matchLobbyId, playerTwo, cosmosDBClient, invitationCode); return(new ResponseWrapper <JoinMatchLobbyResponse> { StatusCode = StatusCode.OK, Response = new JoinMatchLobbyResponse { NetworkId = matchLobby.NetworkId } }); } catch (TicTacToeException exception) { return(TicTacToeExceptionUtil.GetEmptyResponseWrapperFromException <JoinMatchLobbyResponse>(exception)); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient) { var context = await FunctionContext <DeleteMatchLobbyInfoRequest> .Create(req); var matchLobbyRequest = context.FunctionArgument; Settings.TrySetSecretKey(context.ApiSettings); Settings.TrySetCloudName(context.ApiSettings); await MatchLobbyUtil.DeleteMatchLobbyFromDDBBAsync(cosmosDBClient, matchLobbyRequest.Id, matchLobbyRequest.MatchLobbyId); return(new OkObjectResult(matchLobbyRequest)); }
public static async Task <TicTacToeSharedGroupData> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB( databaseName: Constants.DATABASE_NAME, collectionName: Constants.MATCH_LOBBY_TABLE_NAME, ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] IAsyncCollector <MatchLobby> matchlobbyCollection ) { var context = await FunctionContext <CreateMatchLobbyRequest> .Create(req); var playerOne = context.CallerEntityProfile.Lineage.MasterPlayerAccountId; return(await MatchLobbyUtil.CreateMatchLobby(context.AuthenticationContext, context.FunctionArgument.SharedGroupId, playerOne, matchlobbyCollection));; }
public static async Task <MatchLobby> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient, [CosmosDB( databaseName: Constants.DatabaseName, collectionName: Constants.MatchLobbyTableName, ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] IAsyncCollector <MatchLobby> matchlobbyCollection) { var context = await FunctionContext <CreateMatchLobbyRequest> .Create(req); var args = context.FunctionArgument; var creatorId = context.CallerEntityProfile.Entity.Id; return(await MatchLobbyUtil.CreateMatchLobby(args.MatchLobbyId, args.Locked, creatorId, args.NetworkId, matchlobbyCollection, cosmosDBClient)); }
public static async Task <Wrapper <MatchLobbyDTO> > Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient) { var context = await FunctionContext <SearchMatchLobbiesRequest> .Create(req); var lobbyListRequest = context.FunctionArgument; var result = await MatchLobbyUtil.GetMatchLobbiesDTOAsync( cosmosDBClient, ExpressionUtils.GetSearchMatchLobbiesExpression(lobbyListRequest.SearchTerm)); return(new Wrapper <MatchLobbyDTO> { Items = result }); }
public static async Task <MatchLobby> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequestMessage req, [CosmosDB(ConnectionStringSetting = "PlayFabTicTacToeCosmosDB")] DocumentClient cosmosDBClient) { var context = await FunctionContext <LeaveMatchLobbyRequest> .Create(req); var matchLobbyId = context.FunctionArgument.MatchLobbyId; var matchLobby = await MatchLobbyUtil.GetMatchLobbyAsync( cosmosDBClient, (document) => document.MatchLobbyId == matchLobbyId); if (matchLobby == null) { throw new Exception("Match Lobby not found"); } return(await MatchLobbyUtil.LeaveMatchLobby(matchLobby, cosmosDBClient)); }