I've recently discovered the existence of the context parameter in cloudscripts and been using it, to make sure certain handlers would only be called from tasks:
handlers.MyHandler= function(args, context) { // Don't allow this to be triggered by anything but a task if (context.hasOwnProperty("triggeredByTask") && context["triggeredByTask"].hasOwnProperty("Name")) { // Do stuff here ... } }
1.) When using above code, I've noticed the context parameter will not be provided / null for tasks that are run on a player segment? It's been working for the "run cloudscript function once" type of task though.
a) Is this intended? The name "triggeredByTask" certainly suggests, that it would be possible to check it for either type of task.
b) Is there a different way to differentiate between the client calling the handler by itself vs. a task calling the handler for all players in a segment? (Of course there's always the possibility to hand an additional "password-parameter" to the task and check for that, but maybe there's a more elegant way than that?)
2.) Is there any documentation for the context parameter other than the brief mentions in this tutorial (https://api.playfab.com/docs/tutorials/landing-automation/writing-custom-cloud-script), which says
"context is an advanced parameter. In this example, it is null. See this guide(link pending) for more information.This parameter is server-controlled and safe."