I'm trying to develop a online SNS game, and I want to let the game check if the client is outdated or the server is closed. So, I want to make a cloud code that will be called whenever the player request anything, and if the client or the server is closed, it will do something like "Spark.setScriptData("error", true)" and don't let the client connect to the game.
I have tried to make a new event called "Check Update" and call it every time before calling anything else, but this waste a lot of time as it have to call two events and wait for the check update result. So I am figuring how to call a cloud code when player request anything, and " if(outdated) ", it wont call the original request, but only return "Spark.setScriptData("error", true)" .
Thanks for helping.
Best Answer
C
Customer Support
said
about 7 years ago
Hi Chris,
You might find a module quite useful for this, if you navigate to Cloud Code in the Portal you'll find the module tab. If you create a new one that contains your check code in it you can call it by simply placing the following at the top of the Cloud Code for each event you'd like to run the check on.
require("moduleName");
Having this placed at the top of the Cloud Code for each of your events will run the module code before it runs any other Custom Code you may have in the event. In your module code if the checks fail, return the error. Using modules means you will only have to place "require("moduleName");" in each event rather than the full check function itself. This will help keep your cloud code scripts tidy and save time for you.
Thanks,
Liam
1 Comment
Customer Support
said
about 7 years ago
Answer
Hi Chris,
You might find a module quite useful for this, if you navigate to Cloud Code in the Portal you'll find the module tab. If you create a new one that contains your check code in it you can call it by simply placing the following at the top of the Cloud Code for each event you'd like to run the check on.
require("moduleName");
Having this placed at the top of the Cloud Code for each of your events will run the module code before it runs any other Custom Code you may have in the event. In your module code if the checks fail, return the error. Using modules means you will only have to place "require("moduleName");" in each event rather than the full check function itself. This will help keep your cloud code scripts tidy and save time for you.
Chris CHoi
I'm trying to develop a online SNS game, and I want to let the game check if the client is outdated or the server is closed. So, I want to make a cloud code that will be called whenever the player request anything, and if the client or the server is closed, it will do something like "Spark.setScriptData("error", true)" and don't let the client connect to the game.
I have tried to make a new event called "Check Update" and call it every time before calling anything else, but this waste a lot of time as it have to call two events and wait for the check update result. So I am figuring how to call a cloud code when player request anything, and " if(outdated) ", it wont call the original request, but only return "Spark.setScriptData("error", true)" .
Thanks for helping.
Hi Chris,
You might find a module quite useful for this, if you navigate to Cloud Code in the Portal you'll find the module tab. If you create a new one that contains your check code in it you can call it by simply placing the following at the top of the Cloud Code for each event you'd like to run the check on.
require("moduleName");
Having this placed at the top of the Cloud Code for each of your events will run the module code before it runs any other Custom Code you may have in the event. In your module code if the checks fail, return the error. Using modules means you will only have to place "require("moduleName");" in each event rather than the full check function itself. This will help keep your cloud code scripts tidy and save time for you.
Thanks,
Liam
Customer Support
Hi Chris,
You might find a module quite useful for this, if you navigate to Cloud Code in the Portal you'll find the module tab. If you create a new one that contains your check code in it you can call it by simply placing the following at the top of the Cloud Code for each event you'd like to run the check on.
require("moduleName");
Having this placed at the top of the Cloud Code for each of your events will run the module code before it runs any other Custom Code you may have in the event. In your module code if the checks fail, return the error. Using modules means you will only have to place "require("moduleName");" in each event rather than the full check function itself. This will help keep your cloud code scripts tidy and save time for you.
Thanks,
Liam
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics