Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[fix]Changing http server port from 80 to 8000 - 8000 doesn't require sudo to run #2

Merged
merged 1 commit into from

2 participants

@pkrefta

I think title is self-explaining :-)

@hij1nx hij1nx merged commit ff047c7 into hij1nx:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 10 additions and 10 deletions.
  1. +10 −10 server/server.js
View
20 server/server.js
@@ -1,10 +1,10 @@
-
+
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/');
@@ -12,23 +12,23 @@
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;
}
Something went wrong with that request. Please try again.