Hi Ignacio,
Could you ensure the request cloud code itself is running. by logging that too? It may be that the scheduler is not being set in the first instance, rather than it failing to run the scheduled module.
Happy to help - Patrick.
Hello Patrick,
Thank you for your swift reply. I've modified the EVNT_REQUEST_SURPRISE_MODULE event by adding a logging call as you suggested and I can confirm that a new entry with the text "EVNT_REQUEST_SURPRISE_MODULE called" gets created after invoking the event from the test harness, here's the resulting code:
var theScheduler = Spark.getScheduler(); var surpriseModulesScriptData = Spark.getPlayer().getScriptData("surpriseModulesScriptData"); if (surpriseModulesScriptData === null) { Spark.getPlayer().setScriptData("surpriseModulesScriptData", [ { "SURPRISE_MODULE_ID" : "SurpriseModule_Requested" } ] ); } Spark.getLog().info("EVNT_REQUEST_SURPRISE_MODULE called"); theScheduler.inSeconds("EVNT_GRANT_SURPRISE_MODULE", 15, {"SomeArgument" : 10});
Is there any way to get into the internals of the scheduler in order to find out why EVNT_GRANT_SURPRISE_MODULE is not being invoked? Thanks!
Hi Ignacio,
No I'm afraid not. Other than logging as suggested above you could place your module script into a test event and run it there. That way you will be able to debug it in the Test Harness. Once you're happy with how it's performing you can place it in your module in safe in the knowledge that it will execute as expected when called. Does that make sense ?
Regards,
Liam
Hello Liam,
Thank you for your reply. The event that is supposed to be invoked by the scheduler (EVNT_GRANT_SURPRISE_MODULE) is just one line of code:
Spark.getLog().info("EVNT_GRANT_SURPRISE_MODULE called");
I've tried invoking it via the test harness by running this command:
{ "@class": ".LogEventRequest", "eventKey": "EVNT_GRANT_SURPRISE_MODULE" }
and I can see that an entry in the log gets added. But if I try invoking EVNT_REQUEST_SURPRISE_MODULE from the Test Harness, I can see that EVNT_REQUEST_SURPRISE_MODULE is executed but it seems that EVNT_GRANT_SURPRISE_MODULE is not being scheduled. Do you have any other suggestions? Thanks!
Ignacio Liverotti
Hello all. I'm trying to schedule an event using Cloud Code by following the example from https://docs.gamesparks.com/tutorials/cloud-code-and-the-test-harness/scheduling-cloud-code.html, but it seems that the script that should be executed by the scheduler is not being executed.
Here's the event I'm executing via the test harness (notice that I'm running this event after performing an authentication):
and EVNT_GRANT_SURPRISE_MODULE is defined as:
I'm checking the contents of the script.log collection in the NoSQL Explorer, but I cannot see any entries, which makes me think that EVNT_GRANT_SURPRISE_MODULE is not being invoked. Is there any way to debug this code? Thanks in advance!