Created
September 24, 2011 18:42
-
-
Save jcbozonier/1239687 to your computer and use it in GitHub Desktop.
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 app = require('express').createServer() | |
, io = require('socket.io').listen(app); | |
io.configure(function () { | |
io.set("transports", ["xhr-polling"]); | |
io.set("polling duration", 10); | |
}); | |
var port = process.env.PORT || 3000; | |
app.listen(port); | |
app.get('/', function (req, res) { | |
res.sendfile(__dirname + '/index.html'); | |
}); | |
io.sockets.on('connection', function (socket) { | |
socket.broadcast.emit('new_user'); | |
socket.emit('new_user'); | |
socket.on('send_message', function (data) { | |
socket.broadcast.emit('new_message', data); | |
socket.emit('new_message', data); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment