290 likes | 800 Views
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 <br> '); });
E N D
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 • A nodejs module • The cross-browser WebSocket for realtime apps. • Desktop: • Internet Explorer 5.5+ • Safari 3+ • Google Chrome 4+ • Firefox 3+ • Opera 10.61+ • Mobile: • iPhone Safari • iPad Safari • Android WebKit • WebOsWebKit
Socket IO sample Server.js: Client.html: o Ref: http://socket.io/
Demo http://140.96.29.30/nodejs-svn/socketio/chatApp2/index.html
Phone.html?key=OOOOO Index.html Auto generate key and pass key by URL parameter. Connect 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