cloud_synchronise OBSOLETE

This function would normally be called at the start of a new game and is used to retrieve the current status of the cloud service at game start up. The function returns a unique id value which would then be used in the Asynchronous Cloud Event to retrieve the relevant information from the DS map that is created.

This function will send off to the cloud for data, which will then trigger the appropriate asynchronous event. In this event, you can check the returned async_load DS map for the following values:

The exact meaning of the returned "status" map entry is explained in the following table:

Status ValueerrorString / resultStringDescription
-1errorString = "Not logged in to <SERVICE>"You have not successfully logged in to the given Cloud Service
0resultString = recovered dataNew game data downloaded from the cloud (following a cloud_synchronise call)
1resultString = "AlreadySynchronized"No new data since you last called cloud_synchronise
2resultString = "ConflictDeferral"A conflict was encountered, but the gamer chose to ignore it
3resultString = "GameUploadSuccess"data from cloud_string_save() or cloud_file_save() was successfully uploaded to the cloud
-nerrorString = Description of errorAny other negative number means a synchronisation failure

 

Syntax:

cloud_synchronise();

 

Returns:

Async Request ID

 

Extended Example:

This function would be called in an event like the Game Start Event or in an object that is placed in the first room of your game, with the idea being that you check the current data blob from the cloud server to see if it is up to date or not.

cloud_check = cloud_synchronise();

You would then want to check the returned DS Map in the asynchronous Cloud Event to get the status and the returned string, if there is one, with something like the following code:

if (ds_map_find_value(async_load, "id") == cloud_check)
{
    if (ds_map_find_value(async_load, "status") < 0)
    {
        show_message_async("Cloud Services not available. Please check connectivity.");
    }
    else
    {
        if (ds_map_find_value(async_load, "status") == 0)
        {
            var file = file_text_open_write("Save.txt");
            file_text_write_string(file, ds_map_find_value(async_load, "resultString"));
            file_text_close(file);
        }
    }
}

The above code checks to make sure that the correct asynchronous function call is being revised, then goes on to get the status of the returned cloud DS map. if the status is a negative number, something has gone wrong and the user is informed, otherwise the code will continue and retrieve the synchronised data and write it to a text file for later use.