Sign In Register

How can we help you today?

Start a new topic
Answered

Downloadable url via cloud code.

Is it possible to access the url of a downloadable using cloud code?

At the start of our game, I would like to send an event request to update assets using downloadables.

Right now, we have:
- A bunch of downloadables,

- Metacollection containing short codes + version id's of online downloadables.
- Local collection containing short codes + version ids on player's device.


what I would like to have is an event where the player sends his local version ids, and gets a list of urls to download the new files in return.

(like the current request where you get the url of the downloadable, by giving the shortcode, but then in batch)

Right now, I use cloud code to return a list of shortcodes that need to be updated, after which I need to request every url + download the file.

Is it possible to ask the url of a downloadable using cloud code? That way we could almost halve the requests sent to GameSparks for the operation and thus minimize traffic a lot.


Best Answer

Hi Fries,


To access a downloadable URL via cloud code you could create the following event:  

var getDownloadableResponse = Spark.sendRequest({
 "@class": ".GetDownloadableRequest",
 "shortCode": "testDownloadable"
})
 

  This does the standard downloadable request and stores the response in the getDownloadableResponse variable.

 

var downloadableURL = getDownloadableResponse.url;
Spark.setScriptData("DownloadableResponse", downloadableURL);

 

We can then use .url to extract the information from the response.


Oisin.


1 person has this question

Answer

Hi Fries,


To access a downloadable URL via cloud code you could create the following event:  

var getDownloadableResponse = Spark.sendRequest({
 "@class": ".GetDownloadableRequest",
 "shortCode": "testDownloadable"
})
 

  This does the standard downloadable request and stores the response in the getDownloadableResponse variable.

 

var downloadableURL = getDownloadableResponse.url;
Spark.setScriptData("DownloadableResponse", downloadableURL);

 

We can then use .url to extract the information from the response.


Oisin.

The above answer from Oisin is out of date. You can access downloadables directly from cloud code using the following (from https://support.gamesparks.net/support/discussions/topics/1000074358):

 

// array of all of all downloadables
var downloadables = Spark.getConfig().getDownloadables()

// return a single downloadable by shortCode
var downloadable = Spark.getConfig().getDownloadable("downloadableShortCode")

 

 

Login to post a comment