private static async Task PostFunctionResultToPlayFab(PlayerPlayStreamFunctionExecutionContext ctx, object result, long executionTime, ILogger log) { if (ctx.GeneratePlayStreamEvent.HasValue && ctx.GeneratePlayStreamEvent.Value) { await HelperFunctions.PostResults(ctx, nameof(IdentityQueuedPSV1), result, (int)executionTime, log); } }
public static async Task <PlayerProfileModel> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] PlayerPlayStreamFunctionExecutionContext req, HttpRequest httpRequest, ILogger log) { string body = await httpRequest.ReadAsStringAsync(); log.LogInformation($"HTTP POST Body: {body}"); if (req.PlayStreamEventEnvelope != null) { log.LogInformation($"eventEnvelope: {JsonConvert.SerializeObject(req.PlayStreamEventEnvelope)}"); } else { log.LogInformation("PlayStreamEventEnvelope was null"); } if (req.PlayerProfile != null) { log.LogInformation($"playerProfile: {JsonConvert.SerializeObject(req.PlayerProfile)}"); } else { log.LogInformation("PlayerProfile was null"); } return(await Task.FromResult(req.PlayerProfile)); }
public static async Task <object> Run( [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest httpRequest, ILogger log) { string body = await httpRequest.ReadAsStringAsync(); log.LogInformation($"HTTP POST Body: {body}"); PlayerPlayStreamFunctionExecutionContext <object[]> req = JsonConvert.DeserializeObject <PlayerPlayStreamFunctionExecutionContext <object[]> >(body); log.LogInformation($"eventEnvelope: {JsonConvert.SerializeObject(req.PlayStreamEventEnvelope)}"); log.LogInformation($"playerProfile: {JsonConvert.SerializeObject(req.PlayerProfile)}"); return(await Task.FromResult(req.FunctionArgument)); }
public static async Task Run( [QueueTrigger("identitypsv1", Connection = "AzureWebJobsStorage")] string msg, ILogger log) { Stopwatch sw = Stopwatch.StartNew(); log.LogInformation($"{nameof(IdentityQueuedPSV1)} C# queue trigger function processed a request; {msg}"); PlayerPlayStreamFunctionExecutionContext ctx = JsonConvert.DeserializeObject <PlayerPlayStreamFunctionExecutionContext>(msg); // Simulate work await Task.Delay(IdentityQueuedPSV1.delayMilliseconds); // Post results await PostFunctionResultToPlayFab(ctx, ctx.FunctionArgument, sw.ElapsedMilliseconds, log); }
public static Task PostResults(PlayerPlayStreamFunctionExecutionContext ctx, string functionName, object functionResult, int executionTime, ILogger log) { var request = new PostFunctionResultForPlayerTriggeredActionRequest { Entity = new EntityKey { Id = ctx.PlayerProfile.PlayerId, Type = "master_player_account" }, PlayerProfile = ctx.PlayerProfile, PlayStreamEventEnvelope = ctx.PlayStreamEventEnvelope, FunctionResult = new ExecuteFunctionResult { ExecutionTimeMilliseconds = executionTime, Error = null, FunctionName = functionName, FunctionResult = functionResult } }; // TODO: Replace this code with an SDK call once an SDK is published that supports PostFunctionResultForPlayerTriggeredAction return(CallPostResultApi("PostFunctionResultForPlayerTriggeredAction", ctx.TitleAuthenticationContext, request, log)); }