Massive update to use SSE/event-source based HTTPClient


I've made an update to https://github.com/WolfgangSenff/GodotFirebase so that it now uses my other plugin, the HTTPSSEClient. Now, this Godot Firebase plugin correctly uses server-sent events, effectively push notifications, to give you a constant stream of data without making multiple requests. There's currently one slight issue with the update of data, which is that if you're observing a position in your database and you update a *child* of the position you're observing with the Firebase console, it will only update that child and you won't be told that the parent was patched. This means you can't update the correct child in the client-side, because there's no key to indicate what was updated. That said, if you update via code using the SDK, you should be okay because it will update the entire set of data that's being observed.

This update is quite significant. It now gives you the same exact functionality as other Firebase SDKs. It will not work in an exported web build, but I have a few ideas for how to make that possibly work. I've had some success with them, but for some oddball reason, it takes Firebase a *long* time to return the data. It's possibly an issue going from itch.io to Firebase, but I don't know. Here's how it works now:

  1. Download the repo and place the GDFirebase folder into your res://addons folder.
  2. Activate the plugin in your project settings
  3. Add your API key to FirebaseAuth.gd, and your entire Firebase config to FirebaseDatabase.gd, in the places they should obviously go (there are variables for them at the top of each file).
  4. Get a reference to any position in your database by calling Firebase.Database.get_database_reference. You can give it a path and it'll observe that position. Further, you can pass a filter that it will use to decide how to sort or filter out the data given. It is an extremely powerful library. See here for more about querying and filtering: https://firebase.google.com/docs/database/rest/retrieve-data You can add an empty filter perfectly reasonably by just passing { } (empty braces).
  5. Connect to your reference's full_data_update signal. This will return the entire set of data that is currently at the position in your database, according to the filters you've added.
  6. Connect to your reference's new_data_update signal. This will return any new data that has been pushed to the position you're observing in your database.
  7. Connect to your reference's patch_data_update signal. This will give you any updates that happen at the position you're listening to in your database. Note that updating a child of the observed path through the Firebase console, you will get undefined results, but if you use the SDK to update (through the reference.update() call), it should work.

After this, you can push data or update data at will. It is now as fast as Firebase is natively - there are no delays from the SDK at all, and you get pure, raw Firebase speed.

Comments

Log in with itch.io to leave a comment.

Can we get a simplistic example demo of this functionality? :D

(+1)

There's one in there! It shows how to login and how to make a chat app. That said, I'm probably going to make a much more in-depth game as an example with this - my plans are to basically make something like a word-based game, and make YouTube videos describing the entire process. This will just take time.

This would be amazing!

This is awesome! I am going to try this out this weekend.