Skip to content
Browse files

tolto log da chat.js e aggiunto in server.js

  • Loading branch information...
1 parent 9d818d5 commit 4d7038ade49a37919c9144d30169e2c828a0bbf7 @mikosh75 committed Oct 12, 2011
Showing with 16 additions and 6 deletions.
  1. +4 −4 demo/chat.js
  2. +2 −2 lib/router/index.js
  3. +10 −0 lib/server.js
View
8 demo/chat.js
@@ -12,11 +12,11 @@ chatServer.listen(8001);
chatServer.addChannel({
basePath: "/chat/1"
}).addListener("msg", function(msg) {
- sys.puts("1 <" + msg.nick + "> " + msg.text);
-}).addListener("join", function(msg) {
- sys.puts(msg.nick + " join");
+ // sys.puts("1 <" + msg.nick + "> " + msg.text);
+}).addListener("join", function(req, res) {
+ // sys.puts(req.nick + " join" );
}).addListener("part", function(msg) {
- sys.puts(msg.nick + " part");
+ // sys.puts(msg.nick + " part");
});
chatServer.addChannel({
View
4 lib/router/index.js
@@ -71,7 +71,7 @@ router.staticHandler = function (filename) {
return;
}
- sys.puts("loading " + filename + "...");
+ //sys.puts("loading " + filename + "...");
readFile(filename, encoding, function (err, data) {
if (err) {
sys.puts("Error loading " + filename);
@@ -82,7 +82,7 @@ router.staticHandler = function (filename) {
];
headers.push(["Cache-Control", "public"]);
- sys.puts("static file " + filename + " loaded");
+ //sys.puts("static file " + filename + " loaded");
callback();
}
});
View
10 lib/server.js
@@ -1,5 +1,9 @@
var router = require("./router"),
url = require("url"),
+ // aggiunti da michele
+ sys = require("sys"),
+ fs = require("fs"),
+ // fine aggiunta
qs = require("querystring"),
Channel = require("./channel").Channel;
@@ -64,6 +68,9 @@ var handlers = [
}
response.simpleJSON(200, { id: session.id, nick: nick, since: session.since });
+
+ sys.puts(session.id + " " + nick + " join");
+
} },
{ path: "/part", handler: function(channel, request, response) {
var id = qs.parse(url.parse(request.url).query).id;
@@ -91,6 +98,7 @@ var handlers = [
session.poke();
response.simpleJSON(200, { messages: messages });
});
+
} },
{ path: "/send", handler: function(channel, request, response) {
var query = qs.parse(url.parse(request.url).query),
@@ -110,6 +118,8 @@ var handlers = [
session.poke();
var id = channel.appendMessage(session.nick, "msg", text);
response.simpleJSON(200, { id: id });
+ sys.puts(session.id + " " + text);
+
} }
];

0 comments on commit 4d7038a

Please sign in to comment.
Something went wrong with that request. Please try again.