nodejs & socket io
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 PresentationTRANSCRIPT
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'); });s.listen(8083);
o
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.
o
Server.js: Client.html:
Socket IO sample
Ref: http://socket.io/
Demo
http://140.96.29.30/nodejs-svn/socketio/chatApp2/index.html
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
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
Thank you