real-time web apps - meetupfiles.meetup.com/501101/real time web apps.pdfwhy real-time? • 2 or...

107
Real-Time Web Apps Making web apps that respond like desktop apps.

Upload: others

Post on 22-Jul-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Real-Time Web AppsMaking web apps that respond like desktop apps.

Page 2: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What is a real-time web app?

The user is given the latest information without refreshing their browser.

Page 3: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?

Page 4: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?• 2 or more people working on the same thing

(Google Docs)

Page 5: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?• 2 or more people working on the same thing

(Google Docs)

• 2 or more people share a goal (games)

Page 6: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?• 2 or more people working on the same thing

(Google Docs)

• 2 or more people share a goal (games)

• 2 or more people communicating (chat, forums)

Page 7: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?• 2 or more people working on the same thing

(Google Docs)

• 2 or more people share a goal (games)

• 2 or more people communicating (chat, forums)

• presence indicators (Facebook)

Page 8: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Why real-time?• 2 or more people working on the same thing

(Google Docs)

• 2 or more people share a goal (games)

• 2 or more people communicating (chat, forums)

• presence indicators (Facebook)

• letting the user know about things that affect them (background jobs, other users actions)

Page 9: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

How it works

Browser 1Rest

Server

Real Time ServerBrowser 2

Page 10: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

How it works

Browser 1Rest

Server

Real Time ServerBrowser 2

Subscribe

Subscribe

Page 11: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

How it works

Browser 1Rest

Server

Real Time ServerBrowser 2

Subscribe

Subscribe

Page 12: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Methods

• Short polling

• Long polling (aka Comet)

• Web sockets

Page 13: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Short Polling

• Browser asks the server for new info every few seconds.

• Hits the server hard.

Browser

Rest Server

Page 14: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Short Polling

• Browser asks the server for new info every few seconds.

• Hits the server hard.

Browser

Rest Server

Page 15: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Long Polling (Comet)

• Browser asks the server for new info, but waits on the server for a response.

• Immediately re-establishes connection after response.

• Assumes a long HTTP timeout.

Browser

Rest Server

Page 16: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Long Polling (Comet)

• Browser asks the server for new info, but waits on the server for a response.

• Immediately re-establishes connection after response.

• Assumes a long HTTP timeout.

Browser

Rest Server

Are we there yet?

Page 17: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web Sockets

• Browser establishes a connection with the server, and now has bidirectional communication.

• Requires async web app, and web-sockets enabled server.

Browser

Socket Server

Page 18: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web Sockets

• Browser establishes a connection with the server, and now has bidirectional communication.

• Requires async web app, and web-sockets enabled server.

Browser

Socket Server

Page 19: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web Sockets

• Browser establishes a connection with the server, and now has bidirectional communication.

• Requires async web app, and web-sockets enabled server.

Browser

Socket Server

Page 20: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

But wait! There’s more!

Page 21: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Hybrid Rest/Socket

• App doesn’t have to be async.

• Separation of concerns.

• Offload the load.

• If browser isn’t subscribed it will miss messages.

Browser

Rest Server

Socket Server

Page 22: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Hybrid Rest/Socket

• App doesn’t have to be async.

• Separation of concerns.

• Offload the load.

• If browser isn’t subscribed it will miss messages.

Browser

Rest Server

Socket Server

Page 23: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Hybrid Rest/Socket

• App doesn’t have to be async.

• Separation of concerns.

• Offload the load.

• If browser isn’t subscribed it will miss messages.

Browser

Rest Server

Socket Server

Page 24: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Hybrid With Data Store

• Browsers don’t need to be connected right now to receive messages.

• Won’t lose data between page views.

• If not deleted, have archive of data.

Browser

Rest Server

Socket Server

Data Store

Page 25: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Hybrid With Data Store

• Browsers don’t need to be connected right now to receive messages.

• Won’t lose data between page views.

• If not deleted, have archive of data.

Browser

Rest Server

Socket Server

Data Store

Page 26: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Implementations• MeteorServer.org

• Firehose.io

• PubNub.com

• Pusher.com

• Firebase.com

• Dancer::Plugin::WebSocket

• Socket.io

• Mojolicio.us

• Web::Hippie

• Plack::MiddleWare::SocketIO

• And a bajillion more!

Page 27: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Implementations• MeteorServer.org

• Firehose.io

• PubNub.com

• Pusher.com

• Firebase.com

• Dancer::Plugin::WebSocket

• Socket.io

• Mojolicio.us

• Web::Hippie

• Plack::MiddleWare::SocketIO

Page 28: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

Page 29: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

• Open source

Page 30: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

• Open source

• Has its own JS library

Page 31: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

• Open source

• Has its own JS library

• Use LWP or REST::Client to connect

Page 32: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

• Open source

• Has its own JS library

• Use LWP or REST::Client to connect

• Stores data in Redis or RabbitMQ

Page 33: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io

• Open source

• Has its own JS library

• Use LWP or REST::Client to connect

• Stores data in Redis or RabbitMQ

• Starts web sockets, degrades to long polling

Page 34: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.iouse HTTP::Tiny;use JSON;

my $message = {type => ‘error’,data => ‘Something bad happened.’

}

HTTP::Tiny->new->post(‘http://localhost:7474/notifications’,encode_json($message)

);

Page 35: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firehose.io<script src="/firehose.js"></script>

new Firehose.Consumer({uri : ‘http://localhost:7474/notifications’,message : function(message) {

if (message.type == ‘error’) {alert(message.data);

}}

});

use HTTP::Tiny;use JSON;

my $message = {type => ‘error’,data => ‘Something bad happened.’

}

HTTP::Tiny->new->post(‘http://localhost:7474/notifications’,encode_json($message)

);

Page 36: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com

Page 37: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

Page 38: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

• Nice debugging console

Page 39: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

Page 40: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• WWW::Pusher for Perl

Page 41: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• WWW::Pusher for Perl

• No data storage

Page 42: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• WWW::Pusher for Perl

• No data storage

• Starts web sockets, degrades to long polling

Page 43: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.comuse WWW::Pusher;

my $pusher = WWW::Pusher->new(channel => ‘notifications’

);

$pusher->trigger( event => ‘error’, data => ‘Something bad happened.’);

Page 44: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher.com<script src="http://js.pusher.com/2.1/pusher.min.js"></script>

var pusher = new Pusher();var channel = pusher.subscribe(‘notifications’);

channel.bind(‘error’, function(data) {alert(data);

});

use WWW::Pusher;

my $pusher = WWW::Pusher->new(channel => ‘notifications’

);

$pusher->trigger( event => ‘error’, data => ‘Something bad happened.’);

Page 46: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com

Page 47: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

Page 48: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

• Nice debugging console

Page 49: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

Page 50: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• Firebase for Perl

Page 51: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• Firebase for Perl

• Abundant data storage

Page 52: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com• Hosted service, free for

development

• Nice debugging console

• Has its own JS library

• Firebase for Perl

• Abundant data storage

• Starts web sockets, degrades to long polling

Page 53: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.comuse Firebase;

my $firebase = Firebase->new(firebase => ‘jt’

);

$firebase->put(‘notifications’, { type => ‘error’, data => ‘Something bad happened.’});

Page 54: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase.com<script type='text/javascript' src='https://cdn.firebase.com/v0/firebase.js'></script>

var notifications = new Firebase('https://jt.firebaseIO.com/notifications');

notifications.on('child_added', function(message) { if (message.val().type == ‘error’) { alert(message.val().data); }});

use Firebase;

my $firebase = Firebase->new(firebase => ‘jt’

);

$firebase->put(‘notifications’, { type => ‘error’, data => ‘Something bad happened.’});

Page 56: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

Page 57: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

Page 58: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

• Pure Perl

Page 59: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

• Pure Perl

• Roll your own

Page 60: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

Page 61: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

• Can store to any message queue

Page 62: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

• Can store to any message queue

• Web sockets only

Page 63: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocketuse Dancer;use Dancer::Plugin::WebSocket;

dance;

Page 64: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Dancer::Plugin::WebSocket

var ws_path = "ws://localhost:5000/_hippie/ws"; var socket = new WebSocket(ws_path); socket.onopen = function() { document.getElementById('conn-status').innerHTML = 'Connected'; }; socket.onmessage = function(e) { var data = JSON.parse(e.data); if (data.msg) console.log(data.msg); }; function send_msg(message) { socket.send(JSON.stringify({ msg: message })); }

use Dancer;use Dancer::Plugin::WebSocket;

dance;

Page 65: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Demo

Page 66: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

Page 67: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

Page 68: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

• Pure Perl

Page 69: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

• Pure Perl

• Roll your own

Page 70: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

Page 71: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

• Can store to any message queue

Page 72: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Web::Hippie

• Open source

• Pure Perl

• Roll your own

• Has its own JS library

• Can store to any message queue

• Web sockets only

Page 73: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Sound FamiliarThat’s because Web::Hippie is the foundation of

Dancer::Plugin::WebSocket

Page 74: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Demo

Page 75: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

The Real World

Page 76: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 77: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

NotificationsSales, reviews, approvals, order processing.

Page 78: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase

Seller’sBrowser

Wing Socket Server

Data Store

Wingman

Buyer’sBrowser

Page 79: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase

Seller’sBrowser

Wing Socket Server

Data Store

Wingman

Buyer’sBrowser

Page 80: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase

Seller’sBrowser

Wing Socket Server

Data Store

Wingman

Buyer’sBrowser

Page 81: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Large Upload HandlingTake in the file, analyze it, thumb nail it, and upload it to

S3.

Page 82: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 83: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 84: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 85: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Browser

Wing Socket Server

Data Store

WingmanFirebase

Page 86: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Browser

Wing Socket Server

Data Store

WingmanFirebase

Page 87: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Browser

Wing Socket Server

Data Store

WingmanFirebase

Page 88: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

ChatLet users talk to each other on the site.

Page 89: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 90: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal
Page 91: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase

User 2’sBrowser

Socket Server

Data Store

User 1’sBrowser

Maintains Chat History

Page 92: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Firebase

User 2’sBrowser

Socket Server

Data Store

User 1’sBrowser

Maintains Chat History

Page 93: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

@omgtcid thecaptainisdeadomgtcid

Page 94: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

EverythingPlayer movement, interaction with the map,

communication, etc.

Page 95: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Very Early Pre-Alpha

Page 96: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher

Player 2Browser

Wing Socket Server

Player 1Browser

Page 97: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher

Player 2Browser

Wing Socket Server

Player 1Browser

Page 98: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher

Player 2Browser

Wing Socket Server

Player 1Browser

Page 99: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Pusher

Player 2Browser

Wing Socket Server

Player 1Browser

No data store needed because of

command log.

Page 100: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

Page 101: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

Page 102: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

• Reduces the load on the server.

Page 103: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

• Reduces the load on the server.

• Makes hard things possible.

Page 104: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

• Reduces the load on the server.

• Makes hard things possible.

• Can be used in any web app.

Page 105: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

• Reduces the load on the server.

• Makes hard things possible.

• Can be used in any web app.

• Lots of ways to implement it.

Page 106: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

What have we learned?

• Provides a better user experience.

• Reduces the load on the server.

• Makes hard things possible.

• Can be used in any web app.

• Lots of ways to implement it.

• Relatively easy to do.

Page 107: Real-Time Web Apps - Meetupfiles.meetup.com/501101/real time web apps.pdfWhy real-time? • 2 or more people working on the same thing (Google Docs) • 2 or more people share a goal

Questions?