Permalink
Browse files

added comments detailing the contents of the server

  • Loading branch information...
1 parent f0fc7e5 commit 0c3c82c5219765b064e5806db0292bb18705d6a0 Montana Rowe committed Feb 22, 2012
Showing with 26 additions and 2 deletions.
  1. +26 −2 chat_app/server.js
View
@@ -1,9 +1,32 @@
+//Contents
+// Contents
+// modules
+// configuration
+// servers
+// connect
+// socket.io
+// users
+// setUser
+// getUser
+// delUser
+// socket handlers
+// setname
+// getUsers
+// message
+// disconnect
+// connect
+
+
+//modules
var connect = require("connect");
var sio = require("socket.io");
+//configuration
var staticPort = 8000;
var sioPort = 1337;
+//servers
+
//the connect module acts as a factory function that takes middleware arguments
connect(
connect.static(__dirname + "/public")
@@ -14,14 +37,14 @@ connect(
}
);
-
var io = sio.listen(
sioPort,
function(){
console.log("socket server listening on port " + sioPort);
}
);
+
var users = {};
function setUser(name){
var result = getUser(name);
@@ -39,7 +62,7 @@ function delUser(name){
}
-
+//socket handlers
function handleSetname(name,fn){
if(getUser(name)){
fn(true);
@@ -71,4 +94,5 @@ function handleSocketConnect(socket){
socket.on("message", handleMessage);
socket.on("disconnect", handleDisconnect);
}
+
io.sockets.on("connection", handleSocketConnect);

0 comments on commit 0c3c82c

Please sign in to comment.