Permalink
Browse files

Merge pull request #2 from pkrefta/master

[fix]Changing http server port from 80 to 8000 - 8000 doesn't require sudo to run
  • Loading branch information...
2 parents e889010 + d9645d4 commit ff047c7faff92081592157acdee4b2f284a84dd0 Paolo Fragomeni committed Jun 22, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 server/server.js
View
20 server/server.js
@@ -1,34 +1,34 @@
-
+
var fs = require('fs'),
sio = require('socket.io'),
static = require('node-static');
var app = require('http').createServer(handler);
- app.listen(80);
+ app.listen(8000);
var file = new static.Server('./public/');
function handler(req, res) {
file.serve(req, res);
}
- var io = sio.listen(app),
+ var io = sio.listen(app),
nicknames = {};
io.sockets.on('connection', function (socket) {
-
+
socket.on('user message', function (msg) {
-
+
socket.broadcast.emit('user message', socket.nickname, msg);
});
socket.on('nickname', function (nick, fn) {
if (nicknames[nick]) {
-
+
fn(true);
- }
+ }
else {
-
+
fn(false);
nicknames[nick] = socket.nickname = nick;
socket.broadcast.emit('announcement', nick + ' connected');
@@ -37,9 +37,9 @@
});
socket.on('disconnect', function () {
-
+
if (!socket.nickname) {
-
+
return;
}

0 comments on commit ff047c7

Please sign in to comment.