Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var fs = require('fs');
var server = require('http').createServer(handler);
var io = require('').listen(server);
function handler (req, res) {
if (req.url === '/') {
res.statusCode = 200;
res.setHeader('content-type', 'text/html');
io.sockets.on('connection', function (socket) {
socket.on('echo', function (data) {
io.sockets.emit('echo', data, socket.username);
socket.on('setName', function (name) {
socket.username = name;
io.sockets.emit('join', name);

This comment has been minimized.

Copy link

dscape commented Aug 8, 2012

Private gists would be better imho :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.