Code Monkey home page Code Monkey logo

Comments (11)

djhert avatar djhert commented on May 20, 2024 1

Not sure if you have figured this out yet, but for anyone else having this problem it would appear that the function _on_sign_in_success() actually requires a parameter in order to be recognized. So the following does work successfully:
(Note: I prefer to use typed GDScript, so the extra "fluff" can be removed if you want)

func _on_sign_in_success(id : String) -> void:
	print("hello from _on_sign_in_success\nID: %s" % id)

The id parameter that is given looks to be the ID for the Google User.

Similarly, the callback for _on_player_is_already_connected() requires 2 parameters. So the following will work:

func _on_player_is_already_connected(status : bool, id : String) -> void:
	print("hello from _on_player_is_already_connected\nStatus: %s | ID: %s" % [status,id])

The status parameter is either true or false depending on if the user is connected or not, and the id contains the ID once again and should match the one from _on_sign_in_success(). Hope this helps!

from pgsgp.

cgeadas avatar cgeadas commented on May 20, 2024

After some additional testing:
If there is a problem with the auth (wrong sha1 or user just declines google permissions request to use google drive, etc), _on_sign_in_failed callback works and returns an error code. If sign-in is successful, _on_sign_in_success is not called. If the phone is not connect to the internet, the sign-in is still successful - I guess GPGS client libraries do some kind of caching/proxying for the internet connection.

Also, _on_player_is_already_connected doesn't get called (I'm trying to call is_player_connected() somewhere after sign_in()).

My idea is to use is_player_connected to determine if some score related gui itens will be visible or not.

from pgsgp.

cgeadas avatar cgeadas commented on May 20, 2024

I've ended up releasing my game without using this function. But I would like to use on my next one so, this is extremely useful.
How can I know the user ID for checking if he signs in successfully? Do I have to provide the ID when signing in, or is the ID provided by the callback _on_sign_in_success?
Thank you!

from pgsgp.

cgisca avatar cgisca commented on May 20, 2024

@cgeadas I have updated Read me. You can check the correct callback. You don't need to provide the id when signing in. Correct signature of the _on_sign_in_success callback is: func _on_sign_in_success(account_id: String) -> void

Please try again and check if it is working now. Keep in mind to download the latest plugin from tag 1.2.0 (https://github.com/cgisca/PGSGP/releases/tag/1.2.0).

from pgsgp.

tx350z avatar tx350z commented on May 20, 2024

EDIT: I'm submitting an official request to change is_player_connected() to immediately return a result (synchronous) rather than use a callback (asynchronous).

I'm encountering an issue where my app works fine when loaded from Android Studio but does not work when installed from the Play Store. The issue is the spaghetti-code I've had to write just because is_player_connected() uses a callback. The problem is normal code branching based upon the return from is_player_connected() can't be used because of the callback strategy.

Ideally I should be able to write

func _ready():
    If !gpgs.is_player_connected():
        gpgs.sign_in();
    else:
        # do other stuff...

from pgsgp.

cgeadas avatar cgeadas commented on May 20, 2024

@cgisca _on_sign_in_success callback is working ok. However, is_player_connected never triggers the callback.
On a side note, I agree with @tx350z about synchronous results. If it is possible to make it synchronous, it would make my programming much simpler and "clean" than going around with weird gymnastics because of the callbacks. But then, if it programmed like this, it's because it probably has to be like this.

from pgsgp.

tx350z avatar tx350z commented on May 20, 2024

Actually it doesn't have to use callbacks for everything. I added synchronous versions of is_player_connected(), save_snapshot(), and load_snapshot() to the plug-in Java code.

from pgsgp.

cgeadas avatar cgeadas commented on May 20, 2024

@tx350z I (still) don't speak Java :-) so I can't adapt it completely to my needs. Meanwhile, I'll try to deal with the callbacks with a mix of signals and yields - maybe that can work in a manageable way - meaning I'll still be able to understand my code in a few months from now.

from pgsgp.

tx350z avatar tx350z commented on May 20, 2024

Be aware that yield() will not be included in Godot 4.0. Hopefully there will be something similar to allow cooperative multi-threading.

from pgsgp.

cgeadas avatar cgeadas commented on May 20, 2024

@tx350z Thank you for the heads up. I was not aware of that change. I really hope they come up with something useful - sometime those guys are so short-sighted... :-(

from pgsgp.

Losatu avatar Losatu commented on May 20, 2024

_on_player_is_already_connected

I can not a find a signal for this...

from pgsgp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.