[PLUGIN] Firebase

Post your completed addons to share with the community

Post » Sat Mar 01, 2014 8:46 pm

I got asked about how you maintain live data connections to many opponents at the same time. What is the looping stratergy to iterate over multiple records and setup everything in construct 2? Here is the best solution I came up with:

place each JSON player record as a child of "/users/" in your Firebase e.g.
/users/fred/
/users/john/

Create a container object in construct two that associates all the separate graphical elements together (like the label that displays the name). Mine is ui_card, and ui_name, ui_status etc. This example was for a lobby, hence the construct 2 GUI elements were fairly boring sounding objects.

We will use RexRainbow's HashTable (https://www.scirra.com/forum/viewtopic.php?t=65765&start=0) to parse JSON objects coming back from Firebase.

Now to keep all players game objects synced we maintain a list of player data by:
1. register a *child_added* callback to Firebase ref("/users"). This will get called every time a new record is available (including for initialization)
2. create the child_added callback.
2a Create the construct 2 container and register its UID into a player_list dictionary (handy for name lookups later).
2b register a *value* callback on the specific player's record
3. create the callback for when the value of a specific player's record changes. When a networked player's data changes you can load the new data into your graphical representation so it affects the game world immediately.

Image
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Thu Sep 18, 2014 5:52 pm

Hey @tlarkworthy, I started with your firebase plugin and I figured out that there is not a function to register a user with new email and password. It is possible to add it ?
http://armaldio.xyz - Image - Join now our Discord Server ;) - https://discord.gg/0eLPLj96B4tUr1D3

If you like my work you can donate some bucks ;)

Image
B
55
S
16
G
1
Posts: 245
Reputation: 5,638

Post » Thu Oct 30, 2014 7:22 am

May I ask why this plugin could not run at cocoonJS?
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Mon Dec 29, 2014 6:13 am

Hi, sorry about delay. I don't have a windows computer anymore :(
@armaldio
One of the motivations of me putting everything on github is that someone can add missing features fairly easily via a pull request. I don't have a developer setup at the moment to add the feature myself, sorry.
@rexrainbow
Dunno. I don't know what cocoonJS does under the hood. Maybe its a websocket issue, although Firebase should fall back to long polling if that were the case. You can "Firebase.enableLogging(true);" in JS which might explain what the issue is.
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

Post » Mon Dec 29, 2014 9:53 am

@tlarkworthy
@armaldio

I start to develop my firebase plugin here. The authentication is at here.
I still try to add more plugins to help users easy to use firebase by encapsulating more logic into plugin. For example, here is a plugin to save game status (or said webstorage-like structure) on (firebase) cloud.


My team member only had tested them worked in phonegap (excluded authentication). CocoonJs was failed too.


Edit:
I had released some of my firebase plugins at this thread.
Last edited by rexrainbow on Wed Dec 31, 2014 8:49 am, edited 1 time in total.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Tue Dec 30, 2014 4:38 pm

FIrebase is pretty cool, sure I agree, but why isn't anyone mentioning how incredibly expensive the non-"Hacker" Firebase plans are for most of us normal game coders?
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Tue Dec 30, 2014 5:46 pm

@locohost

Hire programmers and own a server all need money, too.
B
108
S
26
G
258
Posts: 4,430
Reputation: 145,179

Post » Wed Dec 31, 2014 3:36 pm

rexrainbow wrote:@locohost

Hire programmers and own a server all need money, too.

Change your handle to mo-money-rainbow! :lol:

No seriously, Firebase is really cool, I said that, however it's just not worth the excessive fees. It's overpriced. You can setup/host your very own full VPS with your very own full MongoDb or CouchDb on a public hosting service for less per month than the just the entry level "Candle" Firebase plan. This all assuming you need more than the "Hacker" plan of course.

Speaking of MongoDb, has anyone wrote a MongoDb C2 plugin? I'll do a search. Maybe that's my next mini project :geek:
B
13
S
4
Posts: 280
Reputation: 1,573

Post » Mon Apr 27, 2015 3:37 am

@locohost - +1 to mongodb! There are a number of providers like MongoHQ and MongoLabs that provide free use for up to 512MB db capacities if you don't want to deploy your own MongoDB server. Then it's $15 - $20 a month per GB complete with the Oplog capabilities (real-time, redundant MongoDB). And not only that, if you connect your data to Mongodb, you can easily use something like Meteor.js to create something to manage your game's backend data if not for something else like a scoreboard, user account management, and such!
B
7
S
1
Posts: 42
Reputation: 1,058

Post » Sat May 02, 2015 10:35 am

A self hosted Mongo is not really the same as Firebase, even with Meteor attached.
Firebase has:
- inbuilt lag compensation so local writes look fresh.
- concurrency synchronization so that writes at the same time get sorted out properly, without db corruption.
- offline support so the app keeps working even when you are playing in a tunnel
- a rich rule language so you can enforce your game constraints.
- authentication with 3rd party providers like Facebook
- static secure *SSL* file hosting
- support for native and server platforms as well as web
- fallback from websockets in case the device is old or the firewall is fussy
- backups
- support
- + a team of people keeping the service running 24/7 and keeping the system up-to date

You can use the SSL and auth for free. The real time database is free for under 50 simultaneous users. That's a lot of users per month as people are not usually online at the same time. If you value your time, you will realize you would spend many, many full time months of labour developing a similar feature set. And it would still take yet more time (in production) to tune it and patch it, to make it reliable for all the internet's random configurations. And all these things are not important, *its the game that is important*, the networking and storage is a distraction, an unwanted time sink.
B
14
S
5
G
1
Posts: 60
Reputation: 1,052

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests