13
Meetup 2 Socket IO Real Time Applications

Node js oc meetup 2 socket io intro

  • Upload
    eddify

  • View
    994

  • Download
    0

Embed Size (px)

DESCRIPTION

Node js oc meetup 2 socket io intro

Citation preview

Page 1: Node js oc meetup 2 socket io intro

Meetup 2Socket IO Real Time Applications

Page 2: Node js oc meetup 2 socket io intro

WIFI

Page 3: Node js oc meetup 2 socket io intro

Who Are We

Eddy@[email protected]

Farsheed@[email protected]

Page 4: Node js oc meetup 2 socket io intro

Overview

Last Meetup RecapWhy Node JSJavascript Intro

TodayRealtime Web Application AchesSocket IO CureExamples

Page 5: Node js oc meetup 2 socket io intro

Real Time Web Applications

Pretty Moving GraphsFeeds (Twitter, News, etc.)ChatroomsHtml5 Multiplayer Games

Page 6: Node js oc meetup 2 socket io intro

Limitations of HTML

HTML Designed for Request/Response1. Browser -> Server2. Server -> Browser3. Repeat

Page 7: Node js oc meetup 2 socket io intro

Solutions

HTML Protocol Hacks:● Short Polling● Long Polling

○ <script>○ AJAX Long Polling

● Streaming○ XMLHttpRequest Multipart Chunks○ Forever Iframe

Page 8: Node js oc meetup 2 socket io intro

Problems with Hacks

● HTTP Overhead for many small updates● Resource Waste in opening and closing

connections● Latency Overhead● Different Implementations for Each Browser

Page 9: Node js oc meetup 2 socket io intro

WebSockets To Rescue!

● Full Web Standard designed for two way communication

● Minimal Overhead for each message

● Most Modern Browsers Support it

Page 10: Node js oc meetup 2 socket io intro

WebSocket Limitations

● HTTP Upgrade Handshake Breaks some older Proxies

● Many Gateways, Load Balancers, Reverse Proxies Servers dont support websocket

● Some Firewalls block Websockets

Page 11: Node js oc meetup 2 socket io intro

Socket IO Got You Covered

Socket IO Real Time Communication Library for both server and client● Abstract Layer over Multiple

Transports ○ Long Polling○ Streaming○ Websockets○ Flashsockets (BLEH)

● Auto Reconnect, Heartbeats, Auto Chooses Best Transport

Page 12: Node js oc meetup 2 socket io intro

Other Good Alternatives

● socksjs● nowjs● engine.io (socket.io but naked)

Page 13: Node js oc meetup 2 socket io intro

How to Get Started

1. express example2. enter example folder3. npm install socket.io --save

Farsheedius Shall walk through the rest

For the impatient: echo examplehttps://github.com/eddify/socketio-starter