Architecting for Data Contention in a Realtime World with Firebase (Google I/O '17)

By: Firebase

80   1   3545

Uploaded on 05/19/2017

Source code for the demo game: https://goo.gl/9l2hra

Building games and apps that maintain state on the backend is easy with Firebase! In this session we'll build (and play!) a turn-based multiplayer game that uses Realtime Database to store game state, Authentication to get players logged in, and Cloud Functions to secure the game logic.

Watch more Firebase talks at I/O '17 here: https://goo.gl/pmO4Dr
See all the talks from Google I/O '17 here: https://goo.gl/D0D4VE

Subscribe to the Firebase channel: https://goo.gl/9giPHG

#io17 #GoogleIO #GoogleIO2017

Comments (12):

By anonymous    2017-09-20

You can certainly move more of your app logic into Cloud Functions. But it's not really true that the only way to invoke a Cloud Function is via HTTP. You can also push data into your database to invoke a database trigger. I gave a talk on this at Google I/O yesterday about how I made a game with all the logic in Cloud Functions. You can watch it here.

Original Thread

By anonymous    2017-09-20

At Google I/O 2017, I gave a talk on building a multiplayer game using only Firebase on the backend. Cloud Functions implements pretty much all the logic of the game. It also has a simple matching feature, and you could extend that scheme to do more complicated things. You can watch the talk here, and source code for the project will be coming soon.

Original Thread

By anonymous    2017-09-20

You'll have to implement something like a command-response model using the database as a relay where you push commands into a location and the function pushes results out that can be listened to by the client that issued the command. The thing that makes this work is the fact that the locations of the commands and responses and known between the client and server, and they have a common knowledge of the push id that was generated for the client command.

I go over this architecture a bit during my session at Google I/O 2017 where I build a turn-based game with Firebase.

An alternative is to use a HTTP function instead, which has a more clearly-defined request-response cycle.

Original Thread

By anonymous    2017-09-23

I'd also recommend Doug Stevenson's I/O talk, which has a section on matchmaking: https://www.youtube.com/watch?v=eWj6dxfN63g

Original Thread

By anonymous    2017-11-20

For applications where security is a high priority, you should always assume that an attacker can compromise the code on the client, since the attacker may be able to manipulate the device any way they want. Because of this, app developers may choose to push critical logic to Cloud Functions in order to retain security.

I gave a talk at I/O 2017 about this, but in the context of game development, where I assume that attackers may compromise game logic. The critical game logic lives in Cloud Functions where it can't be compromised by client-side attacks.

Original Thread

By anonymous    2017-11-27

Watch my talk at Google I/O 2017 - it's about implementing a turn-based game with Firebase. Source code is available. https://www.youtube.com/watch?v=eWj6dxfN63g

Original Thread

By anonymous    2017-12-11

Agree with Michael. You can implement your own queue by pushing into a location at the database to trigger the function. I had a talk on this at I/O. https://www.youtube.com/watch?v=eWj6dxfN63g

Original Thread

By anonymous    2017-12-11

I also talk about this approach here: https://www.youtube.com/watch?v=eWj6dxfN63g&t=690s

Original Thread

By anonymous    2018-03-12

What you're trying to do is not really a supported use case for Cloud Functions. If you want to see how I created a multiplayer turn based game, watch this video: https://www.youtube.com/watch?v=eWj6dxfN63g

Original Thread

Popular Videos 579

Submit Your Video

If you have some great dev videos to share, please fill out this form.