question

jyfdfryyt avatar image
jyfdfryyt asked

Create matchmaking Ticket in CloudScript

If I try to do matchmaking on cloudscript, I get the following response.

Opps Something went wrong: /CloudScript/ExecuteFunction: Invocation of cloud script function Matchmake failed with HTTP status InternalServerError and response body

Please tell me what is wrong. The client code

 PlayFabCloudScriptAPI.ExecuteFunction(new ExecuteFunctionRequest()
  {
             Entity = new PlayFab.CloudScriptModels.EntityKey()
             {
                 Id = PlayFabSettings.staticPlayer.EntityId, 
                 Type = PlayFabSettings.staticPlayer.EntityType
             },
             FunctionName = "Matchmake", 
    
             FunctionParameter = new Dictionary<string, object>() 
                                                 { { "region", "CentralUs" }, { "latency", 50} },
    
             GeneratePlayStreamEvent = true
    
         }, (ExecuteFunctionResult result) =>
         {
         }, (PlayFabError error) =>
         {
         });

The Cloudscript code

 [FunctionName("Matchmake")]
         public static async Task<dynamic> Run(
             [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
             ILogger log)
         {
             FunctionExecutionContext<dynamic> context = JsonConvert.DeserializeObject<FunctionExecutionContext<dynamic>>(await req.ReadAsStringAsync());
    
             dynamic args = context.FunctionArgument;
    
             var message = "";
             var entityProfile = context.CallerEntityProfile;
    
             var api = new PlayFabMultiplayerInstanceAPI(
                 new PlayFabApiSettings
                 {
                     TitleId = context.TitleAuthenticationContext.Id
                 },
                 new PlayFabAuthenticationContext
                 {
                     EntityToken = context.TitleAuthenticationContext.EntityToken
                 }
             );
    
             var apiResult = await api.CreateMatchmakingTicketAsync(
                 new CreateMatchmakingTicketRequest
                 {
                     Creator = new MatchmakingPlayer
                 {
                        
                     Entity = new PlayFab.MultiplayerModels.EntityKey
                     {
                         Id = entityProfile.Entity.Id,
                         Type = entityProfile.Entity.Type
                     },
    
                     Attributes = new MatchmakingPlayerAttributes
                     {
                         DataObject = new
                         {
                             lag = new object[]
                             {
                                 new {
                                     region = args["region"],
                                     latency = args["latency"]
                                 }
                             }
                         }
                     }
    
                 },
                   
                 GiveUpAfterSeconds = 100,
                   
                 QueueName = "1v1"
                    
                 });
    
             return new { messageValue = message + apiResult.Result.TicketId };
         }
CloudScript
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Neils Shi avatar image Neils Shi commented ·

I will do some research.

1 Like 1 ·

1 Answer

·
Neils Shi avatar image
Neils Shi answered

The entity of the CreateMatchmakingTicket API’s caller must be “title_player_account”. So, you cannot use title level entity to call this API in Azure Function. Could you tell us why you want to create matchmaking ticket in Azure Function?

6 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jyfdfryyt avatar image jyfdfryyt commented ·

Because my understanding is that entityAPI should not be called on the client. The reason I think so is because I suspect that hackers will modify the script and use EntityAPI to cheat. I plan to disable AdminAPI, ServerAPI and EntityAPI when I build for the client, am I wrong?

1 Like 1 ·
jyfdfryyt avatar image jyfdfryyt commented ·

My understanding is that entityAPI should not be called by clients. The reason I think so is because I suspect that hackers will modify the script and use EntityAPI to cheat. I plan to disable AdminAPI, ServerAPI and EntityAPI when I build for the client, am I wrong?

1 Like 1 ·
jyfdfryyt avatar image jyfdfryyt commented ·

My understanding is that the EntityAPI should not be called on the client. The reason I think so is because I think hackers might modify the script and use EntityAPI to cheat. I plan to disable AdminAPI,ServerAPI and EntityAPI when building for the client, am I wrong?

0 Likes 0 ·
jyfdfryyt avatar image jyfdfryyt commented ·

Because my understanding is that entityAPI should not be called on the client. The reason I think so is because I suspect that hackers will modify the script and use EntityAPI to cheat. I plan to disable AdminAPI, ServerAPI and EntityAPI when I build for the client, am I wrong?

0 Likes 0 ·
jyfdfryyt avatar image jyfdfryyt commented ·

Because my understanding is that entityAPI should not be called on the client. The reason I think so is because I suspect that hackers will modify the script and use EntityAPI to cheat. I plan to disable AdminAPI, ServerAPI and EntityAPI when I build for the client, am I wrong?

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.