nodejs & socket io

9
Nodejs & Socket IO Jose Chang

Upload: morton

Post on 24-Feb-2016

58 views

Category:

Documents


0 download

DESCRIPTION

Nodejs & Socket IO. Jose Chang. Nodejs. Server side javascript Event-driven Non-blocking I/O. Nodejs sample. var http = require('http'); var s = http.createServer (function ( req , res) { res.writeHead (200, {'content-type': 'text/plain' }); res.end (‘ hello world \n '); }); - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Nodejs  & Socket IO

Nodejs & Socket IO

Jose Chang

Page 2: Nodejs  & Socket IO

Nodejs

• Server side javascript• Event-driven• Non-blocking I/O

Page 3: Nodejs  & Socket IO

Nodejs sample

var http = require('http');var s = http.createServer(function (req, res) { res.writeHead(200, {'content-type': 'text/plain' }); res.end(‘hello world\n'); });s.listen(8083);

o

Page 4: Nodejs  & Socket IO

Socket IO

Desktop:Internet Explorer 5.5+Safari 3+Google Chrome 4+Firefox 3+Opera 10.61+

Mobile:iPhone SafariiPad SafariAndroid WebKitWebOs WebKit

• A nodejs module• The cross-browser WebSocket for realtime

apps.

Page 6: Nodejs  & Socket IO

Demo

http://140.96.29.30/nodejs-svn/socketio/chatApp2/index.html

Page 7: Nodejs  & Socket IO

Auto generate key and pass key by URL parameter.

Connect

Index.html Phone.html?key=OOOOO

Connect Event with key

Event with key

Server.js

Page 8: Nodejs  & Socket IO

Reference• Learning

– DailyJS’s Node Tutorial– Mixu’s Node Book– Node Beginner Book – How To Node

• Framework– Express

• Testing– nodeunit

• Logging– Winston

• IDE– Nide– cloud 9

Page 9: Nodejs  & Socket IO

Thank you