websockets bring light at the end of the tunnel · think. code. collaborate. spiria.com websockets...
TRANSCRIPT
THINK. CODE. COLLABORATE.
spiria.com
Websockets Bring Light at the End of the Tunnel
JOEL LORDPresented by
Node PDX – June 20th, 2016
Aboot me, eh?
JOEL LORD
- Javascript junkie- Tinkerer- Technology enthusiast
@joel__lord #nodepdx
WEB SOCKETS
What are they?
WebSocket is a protocol providing full-duplex communications channels over a single TCP connection.
The WebSocket protocol was standardized by the IETF as RFC 6455 in
2011, and the WebSocketAPI in Web IDL is being standardized by the W3C.
@joel__lord #nodepdx
Typical real-timeNORMAL HTTP REQUESTS
@joel__lord #nodepdx
Client
Server
Time
Typical real-timePOLLING
@joel__lord #nodepdx
Client
Server
Time
Typical real-timeLONG-POLLING
@joel__lord #nodepdx
Client
Server
Time
Typical real-timeWEBSOCKETS
@joel__lord #nodepdx
Client
Server
Time
Typical real-timeWHAT ABOUT SERVER-SIDE EVENTS?
@joel__lord #nodepdx
Client
Server
Time
Pros and cons.
Bi-directional data transfersFast Low bandwith Detects connection and disconnection
01PROS
@joel__lord #nodepdx
Lose the caching capabilities built in XHR and HTTPArchitectural changes in the application
02CONS
@joel__lord #nodepdx
WebSockets in the WildREAL WORLD CASES
@joel__lord #nodepdx
- Real time synchronization of data amongst a group of users (trello.com)
- Live feeds (Twitter stream)
- Long server processes and providing ETAs to users
- Multiplayer HTML5 games
- Chat clients (Slack)
Using WebSockets with HTML5ESTABLISHING A CONNECTION
@joel__lord #nodepdx
Using WebSockets with HTML5EVENTS
@joel__lord #nodepdx
Using WebSockets with HTML5SENDING DATA TO THE SERVER
@joel__lord #nodepdx
Getting startedVARIOUS IMPLEMENTATIONS
@joel__lord #nodepdx
- PubNub (cloud)
- Ratchet (php)
- Jetty (Java)
- socket.io (node.js)
Here comes Socket.io!WHAT’S SO COOL ABOUT IT?
@joel__lord #nodepdx
- Server and client-side implementation
- Falls back to long polling when necessary (IE 9 😱)
- Adds features like heartbeats, timeouts, and disconnection support not
provided in WebSocket API
- Easy stuff !
Here comes Socket.io!CLIENT SIDE
@joel__lord #nodepdx
Here comes Socket.io!SERVER SIDE
@joel__lord #nodepdx
LET’S GET SERIOUS
Coding time!
THINK. CODE. COLLABORATE.
spiria.com
The end!
JOEL LORD
Node PDX – June 20th, 2016
Presented by @joel__lord #nodepdx
/joellord