Ejemplo n.º 1
0
        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));
            }
        }
Ejemplo n.º 2
0
        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));
            }
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 4
0
        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));;
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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
            });
        }
Ejemplo n.º 7
0
        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));
        }