loadAllGameData callback

Hi there!
I’m facing some problems using loadAllGameData method. If I understood it correctly, loadAllGameData will trigger an onLoadGameData callback for every savefile the user have on the cloud. My problem is that I need to force synchro with one of the savefiles every time the user open the app (by design). If the save doesn’t exist, no callback will be called and the game hangs.

@yinjimmy Is there a way I can ask the plugin if a certain save exists?

Thanks! :slight_smile:
fryderyk

Anyway, I have thinking a bit more about this… I think that all asynchronous calls must have at least a callback (maybe we can make it a programming rule xD) so it can be interesting that if no savefile exists, a noGameDataToLoad callback or something similar is called instead. What do you think about that?

Thanks again! :slight_smile:
fryderyk

how about trigger onLoadGameData with error null when all data load finished.

Yes, we need solution for this. Its required.

Hey! @htlxyz, error null is a normal behaviour of the onLoadGameData if everything is ok, maybe you wanted to say a savedData null.

Yesterday, I had a talk with some friends that are using some Unity plugin in their game and they have a nice solution for this problem. They have a method that fetches all metadata before actually downloads any savefile. In our case I think we can have something like this:


void fetchAllSaveFiles(std::function< void(std::vector< std::string>)>);

With this method that has to callback in all cases (empty vector if something is wrong or no data is on the cloud), we can do something like this (CloudManager has a std::vector<string> _saveFilesToRead; attribute and manages all callbacks from sdkbox):


void CloudManager::load()
{
    sdkbox::PluginSdkboxPlay::fetchAllSaveFiles([this](std::vector< std::string> saveFiles)
    {
        if(saveFiles.size() > 0)
        {
            for(std::string saveFile : saveFiles)
                _saveFilesToRead.push_back(saveFile);

            sdkbox::PluginSdkboxPlay::loadAllGameData();
        }
        else
        {
            // Do your end reading data stuff
        }
    });
}

Then in the callback we do this:


void CloudManager::onLoadGameData(const sdkbox::SavedGameData* savedData, const std::string& error)
{
    if(error == "" && savedData->dataLength > 0)
    {
        // Read the saveFile stuff
    }

    _saveFilesToRead.erase(std::remove(_saveFilesToRead.begin(), _saveFilesToRead.end(), savedData->name), _saveFilesToRead.end());
    if(_saveFilesToRead.size() == 0)
    {
        // Do your end reading data stuff
    }
}

I think this is a nice solution and can cover the needs of everyone :slight_smile:

What do you think about this? Is it possible?

Thanks!
fryderyk

@yinjimmy might have more advice.

@fryderyk88

yep, it should be savedData null.

when loadAllGameData invoke, will always get this event onLoadGameData(null, "") to indicate load finish.

and your solution, it’s a good idea.

you want to get keys first, and then you can decide to which key you want to get it’s value.

we need think about how to give the api. maybe will not use std::function, we must think about compatible thing.

now we send onLoadGameData(null, "") when load finish, it’s on staging server.
you can take a try by run sdkbox update --staging

2 Likes

I tried sdkbox update --staging but I get this:


  _______ ______  _     _ ______   _____  _     _
  |______ |     \ |____/  |_____] |     |  \___/
  ______| |_____/ |    \_ |_____] |_____| _/   \_
 Copyright (c) 2016-2017 SDKBOX Inc. v1.0.1.32
  _                          _
 |o|  o ,      o_,'   o_,   |o|
 |O| <%'.   _`'_ ===  <\_   |O|
 (0) /  |  (_)`-' |    / |  (0)
 p----------------------------g
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 2.3.17.7 2.3.17.7
 all packages are up to date.

It seems to have updated nothing :frowning:

Ohhh!! It seems that it have actually been updated. Maybe the command output must be changed because is a bit confusing :smile:

Compiling to test, I’ll update with the results soon…

try this.

download && sdkbox import ./path/to/sdkbox-sdkboxplay_v2.3.17.7.tar.gz

Sorry for the delay, I tested with the .tar.gz from dropbox, it doesn’t work :frowning:

Test case:
I have tried the game with a fresh account (so there is no files in cloud) and the callback is never called (i’m working on android).

can you get onLoadGameData(null, "") when use other account which store data in cloud

i review our code, there is a bug when no data in cloud. we will fix this. @fryderyk88

@fryderyk88

  1. fixed finish event not trigger
  2. add fetchGameDataNames, loadOneGameData api according to your solution.
1 Like

Now it works like a charm!
I haven’t tested the new methods yet, but they sound good :slight_smile:

Thanks!!!
fryderyk

hi there @htlxyz! We have recently started the iOS QA and we have found a rare issue on this library (on android seems to be working well). The steps I do to reproduce the issue:

  1. Install the game and play until we save a file on cloud.
  2. Uninstall the game.
  3. Do a fresh install, when onGameDataNames is called, the names array is empty.
  4. Close the game and reopen, names array from onGameDataNames contains the file name.

We have tested this with different devices and iOS versions and no one can retrieve the info on the first launch after a fresh install. Any ideas?

Thanks in advance!! :slight_smile:

i checked our code, i figure out this, we invoke fetchSavedGamesWithCompletionHandler, but this function just return nil with no error. i guess this maybe a apple issue.

FYI: https://forums.developer.apple.com/thread/65578

Ohhh I see… I have made a workaround, it’s nasty, but seems to work. What a shame that Apple hasn’t solved a bug (in my opinion, a critical one) reported half and a year ago…

Thanks for your help!