Esempio 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));
            }
        }
Esempio 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));
            }
        }