/// <summary> /// Generate an entity PlayStream event for the provided function result. /// </summary> public void PostFunctionResultForEntityTriggeredAction(PostFunctionResultForEntityTriggeredActionRequest request, Action <EmptyResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext; var callSettings = apiSettings ?? PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) { throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method"); } PlayFabHttp.MakeApiCall("/CloudScript/PostFunctionResultForEntityTriggeredAction", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this); }
public static Task PostResults(EntityPlayStreamFunctionExecutionContext ctx, string functionName, object functionResult, int executionTime, ILogger log) { // public CloudScriptModels.EntityKey Entity { get; set; } var request = new PostFunctionResultForEntityTriggeredActionRequest { Entity = new EntityKey { Id = ctx.CallerEntityProfile.Entity.Id, Type = ctx.CallerEntityProfile.Entity.Type }, //CallerEntityProfile = ctx.CallerEntityProfile, //PlayStreamEvent = ctx.PlayStreamEvent, 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 PostFunctionResultForEntityTriggeredAction return(CallPostResultApi("PostFunctionResultForEntityTriggeredAction", ctx.TitleAuthenticationContext, request, log)); }
/// <summary> /// Generate an entity PlayStream event for the provided function result. /// </summary> public async Task <PlayFabResult <EmptyResult> > PostFunctionResultForEntityTriggeredActionAsync(PostFunctionResultForEntityTriggeredActionRequest request, object customData = null, Dictionary <string, string> extraHeaders = null) { await new PlayFabUtil.SynchronizationContextRemover(); var requestContext = request?.AuthenticationContext ?? authenticationContext; var requestSettings = apiSettings ?? PlayFabSettings.staticSettings; if (requestContext.EntityToken == null) { throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call Client Login or GetEntityToken before calling this method"); } var httpResult = await PlayFabHttp.DoPost("/CloudScript/PostFunctionResultForEntityTriggeredAction", request, "X-EntityToken", requestContext.EntityToken, extraHeaders, requestSettings); if (httpResult is PlayFabError) { var error = (PlayFabError)httpResult; PlayFabSettings.GlobalErrorHandler?.Invoke(error); return(new PlayFabResult <EmptyResult> { Error = error, CustomData = customData }); } var resultRawJson = (string)httpResult; var resultData = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <EmptyResult> >(resultRawJson); var result = resultData.data; return(new PlayFabResult <EmptyResult> { Result = result, CustomData = customData }); }