Realtime Web Apps in 2014 & Beyond

Preview:

DESCRIPTION

It has been possible to instantly push information from a web server to a web browser for at least 10 years, but this technology has finally gone mainstream thanks to technologies like WebSockets and solutions like SignalR, socket.io, Faye and Pusher. In this sessions I'll cover the past, present and future of client/server communication technology, the realtime web and provide a number of use cases and demonstrations of how the technology is actually used today (it's not just chat and spaceship games).

Citation preview

Realtime Web Apps

In 2014 & BeyondPhil @leggetter

Realtime Web Apps

↓s/Web/Internet

↓Realtime Internet Apps

The Internet...1. is the communications platform

2. is becoming the entertainment platform

When do we need Realtime?

DataIs there a timely nature to the data?

User ExperienceIs there a timely nature to the experience?

Realtime is required when there's aNeed or Demand for:

Up to date informationInteraction to maintain engagement

These aren't new Needs orDemands

HTTP, Browsers & Servers made

it Difficult

What made it difficult?HTTP - request/response paradigmKeeping persistent HTTP connections aliveNo cross-browser XMLHttpRequest2 connection limitNo browser cross origin supportGeneral cross browser incompatibilities

Hacks & TricksJava AppletsFlashHTTP Hacks

Driving Forces behind the Hacks?

Realtime Going Mainstream

A Realisation & Demonstration of

Value

Accessible Realtime Technology

Improved Server PowerProcessors and Memory are cheaper & fasterMore data can be processesConnections can be dealt withScaling is easier

Web Browser Capabilities andConsistency

Cross browser XMLHTTPRequest supportCORSServer Sent Events / EventSourceWebSocketWebRTC

Software ChoiceLots of language & runtime optionsMore open source solutionsHosted services

Any Client Technology

Realtime Apps in 2014

Notifications & Signalling

Internet ^5 Machine

0:48

talky.io

Receive message

var sock = new SockJS( 'http://localhost:9999/sockjs' );

sock.onmessage = function( e ) {

console.log( 'message', e.data );

};

Send Message

var http = require('http');

sockjs = require('sockjs');

var hello = sockjs.createServer();

hello.on( 'connection' , function( conn ) {

conn.write( 'hello SockJS' );

} );

var server = http.createServer();

hello.installHandlers( server, { prefix:'/sockjs' } );

server.listen( 9999, '0.0.0.0' );

Simple Messaging SolutionsServer/Server

WebHooksClient/Server

WebSocket-only or HTTP-only solutions

Peer-to-Peer

SockJSEngine.IOPrimus

simpleWebRTCPeerJS

Lots of Data

0:55

Subscribe

var pusher = new Pusher( APP_KEY );

var channel = pusher.subscribe( 'game-overview' );

channel.bind( 'goal_scored', function( data ) {

// Handle Update

} );

channel.bind( 'time_updated', function( data ) {

} );

Publish

var pusher = new Pusher( APP_KEY );

var data = { team_id = 'manchester_city',

goals_scored: 2,

goal_scorer: 'Sergio Agüero' };

pusher.trigger( 'game-overview', 'goal_scored', data );

PubSub SolutionsSelf Hosted

Hosted

Socket.IOFayeXSockets

GoInstantHydnaPubNubPusherRealtime.co

Complex Client/Server

Interactions

Server

public class GameHub : Hub {

public void Move(Player p, int x, int y) {

// Check if move is allowed

// Call the broadcastMessage method to update clients.

Clients.All.playerMoved(p, x, y);

}

}

Client

$.connection.hub.start(); // async

var game = $.connection.gameHub;

game.client.playerMoved = function (player, x, y) {

// update game

};

game.server.move( me, x, y );

RMI SolutionsSelf Hosted:

Hosted:SignalR on Windows Azure?

dNodeSignalRJava.rmi

Collaborating on Data

Physical Collaborative Mapping

1:10

DataSync

var myDataRef = new Firebase('https://my-app.firebaseio.com/');

myDataRef.push( {creator: '@leggetter', text: 'Not a Test!'} );

myDataRef.on( 'child_added', function(snapshot) {

// Add the data

});

myDataRef.on( 'child_changed', function(snapshot) {

// Update the data

});

myDataRef.on( 'child_removed', function(snapshot) {

// Remove the data

});

Data Sync SolutionsSelf Hosted:

+ Hosted:

DerbyJSMeteorCouchDB pouchdb

FirebaseGoogle Drive Realtime APIGoInstantRealtime.coSimperium

Choosing a Solution

Beyond

Network InfrastructureReliablitySpeedBeyond HTTP

More "Things"!

0:32

And APIs...

Use RealtimeTwilioSendGridMailChimpIron.ioGitHubTrello...

APIs for APIsFanout.io

IoT PlatformsSmartThingsNinjaBlocksEvryThingSKYNET.im

MQTT

MQTT is a machine-to-machine(M2M)/"Internet of Things"connectivity protocol.

MQTTHiveMQEclipse Paho

Multi-Device Experiences

Watch_Dogs

1:07

Realtime Internet Apps =

Internet of Things =

Web Browsers +Web Servers +Native Apps +

Devices +

Thanks!

Questions?

Phil @leggetterBladeRunnerJS

j.mp/realtime-sotr14j.mp/realtime-tech-guide