spookygames / gdx-gameservices

Game services wrapper for libgdx.
MIT License
6 stars 1 forks source link

Callback have a strange behavior #2

Closed Lucidarme closed 3 years ago

Lucidarme commented 7 years ago

I notice a really strange behavior about callback. When I do:

myConnectionHandler.getScores("lead1", ldo, new ServiceCallback<Iterable<LeaderboardEntry>>() {
                   @Override
                   public void onSuccess(Iterable<LeaderboardEntry> result, ServiceResponse response) {
                             Gdx.app.log("gdx-gamesservices", "success ");
                   }

                   @Override
                   public void onFailure(ServiceResponse response) {
                           Gdx.app.error("gdx-gamesservices", "failure = " + response.getErrorMessage());
                   }
           });

all works fine. But when I want to do some actions in onSuccess function, like add result in a table, it doesn't work and both onSuccess and onFailure are called ! At first I thought it was my changes, but this issue is present with the real playtomic server-api. Here is a code when it doesn't work:

final Table table = new Table();
final LabelStyle labelStyle = new Labelstyle();
myConnectionHandler.getScores("lead1", ldo, new ServiceCallback<Iterable<LeaderboardEntry>>() {
                    @Override
                    public void onSuccess(Iterable<LeaderboardEntry> result, ServiceResponse response) {
                            Gdx.app.log("gdx-gamesservices", "success ");
                            Label label;
                            for(LeaderboardEntry l : result){
                                label = new Label("" + result.getPlayerId(), labelStyle);
                                table.add(label).row();
                            }
                    }

                    @Override
                    public void onFailure(ServiceResponse response) {
                            Gdx.app.error("gdx-gamesservices", "failure = " + response.getErrorMessage());
                    }
        });

Here is the output:

image

This problem not happen all time, in some rare case it works, but in any case, it never works in a listener of something else ( a scrollPane in my case).

arthurtemple commented 6 years ago

Could you please provide a sample working project showing this behaviour?

arthurtemple commented 6 years ago

You may try to contact your Playtomic server from the demo by calling ./gradlew :gdx-gameservices-playtomic:demo and see what happens. I was unable to reproduce your issue on my side.

Lucidarme commented 6 years ago

I'll try to provide a sample soon !

arthurtemple commented 3 years ago

I guess this is no longer a problem. :thinking:

Feel free to re-open if needed.