+ All Categories
Home > Technology > GDG Firebase - Building a Goban app

GDG Firebase - Building a Goban app

Date post: 15-Jul-2015
Category:
Upload: sfeir
View: 190 times
Download: 0 times
Share this document with a friend
48
the Realtime App Platform Firebase
Transcript

the Realtime App Platform

Firebase

About

Didier GIRARDGoogle Developers Expert

@didiergirard

Cedric TESNIERESoftware Engineer at Sfeir

@cedric_tesniere

Goban

What Didier asked me ?

Build a game

Realtime ScalableOffline

My solution

5 Days

Learning Firebase

What ?

Works onevery platform

BaaS

What for ?

Build Realtime Apps

How ?

SynchronisationStorage

How to use

How to use

SDKREST API

Viewing data

= https://library-demo.firebaseio.com/

= https://library-demo.firebaseio.com/books

= Unique Id

Rest Interface with HTTPS

$ curl -X POST -d '{

"name": "Steve Jobs",

"author": "Walter Isaacson"

}' \

https://library.firebaseio.com/books.json

Accessing Firebase Data

//CREATE A FIREBASE

var fb = new Firebase("https://library.firebaseio.com/books");

Accessing Firebase Data

//CREATE A FIREBASE

var fb = new Firebase("https://library.firebaseio.com/books");

//SAVE DATAfb.push({ name: "Steve Jobs", author: "Walter Isaacson"});

Accessing Firebase Data

//CREATE A FIREBASE

var fb = new Firebase("https://library.firebaseio.com/books");

//SAVE DATAfb.push({ name: "Steve Jobs", author: "Walter Isaacson"});

//LISTEN FOR REALTIME CHANGESfb.on("value", function(data) { var book = data.val(); console.log("New book:" + book.name + ";author:" + book.author);});

Accessing Firebase Data

child(childPath)

parent()

root()

Navigating in references

Asynchronous callback

set(value, [onComplete])

update(value, [onComplete])

push([value], [onComplete])

transaction(updateFunction, [onComplete], [applyLocally])

Save Data

query on Firebase

Queries

NoSQL data storage

No JOIN statements

No WHERE clauses

Queries

on(eventType, callback, [cancelCallback], [context])

off([eventType], [callback], [context])

once(eventType, successCallback, [failureCallback], [context])

Event Type

value

child_added

child_changed

child_removed

child_moved

Simple Query

var fb = new Firebase("https://library.firebaseio.com");

SELECT * from users WHERE user_id={id}

fb.child('/users/{id}/');

Complex Query

var fb = new Firebase("https://library.firebaseio.com");

fb.child('books/{id}').once('value', function(bookSnap) {

fb.child('author/' + snap.val().authorId)

.once('value',function(authorSnap) {

console.log(bookSnap.val(), authorSnap.val());

});

});

Firebase Rules (schema)

Default

{

"rules": {

".read": true,

".write": true

}

}

Firebase Rules (schema)

{

"rules" : {

".read" : true,

".write" : 'auth != null',

"books" : {

"$booksId" : {

".validate" :

"newData.hasChildren(['author', 'name'])

&& newData.child('author').isString()

&& newData.child('name').isString()"

}

}

}

}

limitsfor all

Depth of child nodes

32

Length of a key

768 bytes

Size of one child value

10mb

Write from SDK16mb (UTF8)

Write from REST256mb

Nodes in a read operation

100 million

Goban

Rules of Go

Model

REST

WebSockets

Sync

New Game withtwo players

Problems and needs

Concurrent access to data

Presence

Add stones

Check of token

Switch the token

Problems and needs

List of games

Show last game

Show score

Problems and needs

Security

Oauth

Security (Firebase rules)

Problems and needs

And after that?

And after that?

- Multiplayer game- Remote controller- Remake :

- Google Doc - Uber

- ...

Resources

- Try Firebase : http://www.firebase.com/tutorial

- More information :https://www.firebase.com/docs/ https://www.firebase.com/blog/

- Source Codehttps://github.com/sfeir/goban

Thank You!

Questions anyone?

@cedric_tesniere


Recommended