Access request script data in the response handler
O
Ovidiu Buligan
started a topic
almost 8 years ago
I want to access the scriptdata I set in the request in the response handler.
Is it possible ? Is there a safe workaround ?
Best Answer
O
Ovidiu Buligan
said
almost 8 years ago
Thank you very much for your reply. Your suggestion helped . I implemented
function setRequestData(){
var data = Spark.getData()["requestData"];
Spark.setScriptData("scriptData",data);
}
function getRequestData(){
var data =Spark.getData()["scriptData"]["requestData"];
return data;
}
I have some minor annoyances with it. now that data is also persisted down to the client and I have to manually remove the "requestData" before cloud code exits ..
Once u set data in Request cloud code with above method, the data will be passed to Response cloud code and inturn to the client.
here is an example -
Request cloud code
Spark.SetScriptData("state","RUNNING");
Response Cloud code:
var state = Spark.getData().scriptData["state"];
This as per documentation of Spark class.
When scriptData is set to a request, it gets set against the response that will be returned to the player. This allows basic communication between request and response scripts.
Let me know if you have any trouble in using this.
O
Ovidiu Buligan
said
almost 8 years ago
Answer
Thank you very much for your reply. Your suggestion helped . I implemented
function setRequestData(){
var data = Spark.getData()["requestData"];
Spark.setScriptData("scriptData",data);
}
function getRequestData(){
var data =Spark.getData()["scriptData"]["requestData"];
return data;
}
I have some minor annoyances with it. now that data is also persisted down to the client and I have to manually remove the "requestData" before cloud code exits ..
Do you have any idea ?
A
Ayyappa R
said
almost 8 years ago
Glad it helped. I didn't find any other option other than clearing it in response code handler if you don't want it to reach client .
May be Sparks team can give more info on this.
O
Ovidiu Buligan
said
almost 8 years ago
Sorry for asking you this but .. if you have some knowledge about facebook login , could you look at my facebook login question ?
Ovidiu Buligan
I want to access the scriptdata I set in the request in the response handler.
Is it possible ? Is there a safe workaround ?
Thank you very much for your reply. Your suggestion helped . I implemented
I have some minor annoyances with it. now that data is also persisted down to the client and I have to manually remove the "requestData" before cloud code exits ..
Do you have any idea ?
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstAyyappa R
You can use Spark.SetScriptData to do that.
Once u set data in Request cloud code with above method, the data will be passed to Response cloud code and inturn to the client.
here is an example -
This as per documentation of Spark class.
Let me know if you have any trouble in using this.
Ovidiu Buligan
Thank you very much for your reply. Your suggestion helped . I implemented
I have some minor annoyances with it. now that data is also persisted down to the client and I have to manually remove the "requestData" before cloud code exits ..
Do you have any idea ?
Ayyappa R
Glad it helped. I didn't find any other option other than clearing it in response code handler if you don't want it to reach client .
May be Sparks team can give more info on this.
Ovidiu Buligan
Sorry for asking you this but .. if you have some knowledge about facebook login , could you look at my facebook login question ?
https://support.gamesparks.net/support/discussions/topics/1000055064
-
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