node js oc meetup 2 socket io intro

Post on 11-May-2015

994 Views

Category:

Technology

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

Node js oc meetup 2 socket io intro

TRANSCRIPT

Meetup 2Socket IO Real Time Applications

WIFI

Who Are We

Eddy@eddydkimeddy@drumbi.com

Farsheed@captainateffarsheed@drumbi.com

Overview

Last Meetup RecapWhy Node JSJavascript Intro

TodayRealtime Web Application AchesSocket IO CureExamples

Real Time Web Applications

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

Limitations of HTML

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

Solutions

HTML Protocol Hacks:● Short Polling● Long Polling

○ <script>○ AJAX Long Polling

● Streaming○ XMLHttpRequest Multipart Chunks○ Forever Iframe

Problems with Hacks

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

connections● Latency Overhead● Different Implementations for Each Browser

WebSockets To Rescue!

● Full Web Standard designed for two way communication

● Minimal Overhead for each message

● Most Modern Browsers Support it

WebSocket Limitations

● HTTP Upgrade Handshake Breaks some older Proxies

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

● Some Firewalls block Websockets

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

Other Good Alternatives

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

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

top related