Created
August 8, 2012 20:04
-
-
Save anonymous/3298101 to your computer and use it in GitHub Desktop.
Nodejitsu Socket.io on express.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = http.createServer(app).listen(app.get('port'), function() { | |
console.log("Express server listening on port " + app.get('port')); | |
}); | |
// Socket.io | |
var io = require('socket.io').listen(server); | |
io.sockets.on('connection', function (socket) { | |
socket.on('new message', function (data) { | |
io.sockets.emit('update', { update: data.message }); | |
}); | |
socket.on('save', function (data) { | |
console.log("Save this to CouchDB", data.array); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment