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