Created
September 12, 2012 00:37
-
-
Save cdolan/3703296 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 net = require('net'); | |
var chatroom = []; | |
var server = net.createServer(function(user) { | |
user.on('connect', function() { | |
console.log('user connected'); | |
chatroom.push(user); | |
}); | |
user.on('data', function(data) { | |
for (var i = 0; i < chatroom.length; i++) { | |
chatroom[i].write(data); | |
} | |
}); | |
user.on('end', function() { | |
console.log('user disconnected'); | |
}); | |
}); | |
server.listen(3000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment