Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Revert 3a5373a^..HEAD

  • Loading branch information...
commit 6f135cd4bc84a6b5b5ebe968ed6e93a5b58ed4cf 1 parent ff0ff41
mikosh75 authored
14 demo/chat.js
@@ -10,19 +10,9 @@ chatServer.listen(8001);
10 10
11 11 // create a channel and log all activity to stdout
12 12 chatServer.addChannel({
13   - basePath: "/chat/1"
  13 + basePath: "/chat"
14 14 }).addListener("msg", function(msg) {
15   - // sys.puts("1 <" + msg.nick + "> " + msg.text);
16   -}).addListener("join", function(req, res) {
17   - // sys.puts(req.nick + " join" );
18   -}).addListener("part", function(msg) {
19   - // sys.puts(msg.nick + " part");
20   -});
21   -
22   -chatServer.addChannel({
23   - basePath: "/chat/2"
24   -}).addListener("msg", function(msg) {
25   - sys.puts("2 <" + msg.nick + "> " + msg.text);
  15 + sys.puts("<" + msg.nick + "> " + msg.text);
26 16 }).addListener("join", function(msg) {
27 17 sys.puts(msg.nick + " join");
28 18 }).addListener("part", function(msg) {
27 demo/web/js/client.js
... ... @@ -1,21 +1,8 @@
1 1 (function($) {
2 2
3   -var urlParams = {};
4   -(function () {
5   - var e,
6   - a = /\+/g, // Regex for replacing addition symbol with a space
7   - r = /([^&=]+)=?([^&]*)/g,
8   - d = function (s) { return decodeURIComponent(s.replace(a, " ")); },
9   - q = window.location.search.substring(1);
10   -
11   - while (e = r.exec(q))
12   - urlParams[d(e[1])] = d(e[2]);
13   -})();
14   -
15   -
16 3 var title = document.title,
17 4 colors = ["green", "orange", "yellow", "red", "fuschia", "blue"],
18   - channel = nodeChat.connect("/chat/" + urlParams["ch"]),
  5 + channel = nodeChat.connect("/chat"),
19 6 log,
20 7 message;
21 8
@@ -174,16 +161,6 @@ $(function() {
174 161 .focus();
175 162 }
176 163
177   - function randomString(len, charSet) {
178   - charSet = charSet || 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
179   - var randomString = '';
180   - for (var i = 0; i < len; i++) {
181   - var randomPoz = Math.floor(Math.random() * charSet.length);
182   - randomString += charSet.substring(randomPoz,randomPoz+1);
183   - }
184   - return randomString;
185   - }
186   -
187 164 var login = $("#login");
188 165 login.submit(function() {
189 166 var nick = $.trim($("#nick").val());
@@ -194,8 +171,6 @@ $(function() {
194 171 return false;
195 172 }
196 173
197   -// var nick = "user_" + randomString(5);
198   -
199 174 channel.join(nick, {
200 175 success: function() {
201 176 $("body")
2  lib/channel.js
@@ -11,7 +11,7 @@ function Channel(options) {
11 11
12 12 this.basePath = options.basePath;
13 13 this.messageBacklog = parseInt(options.messageBacklog) || 200;
14   - this.sessionTimeout = (parseInt(options.sessionTimeout) || 180) * 1000;
  14 + this.sessionTimeout = (parseInt(options.sessionTimeout) || 60) * 1000;
15 15
16 16 this.nextMessageId = 0;
17 17 this.messages = [];
4 lib/router/index.js
@@ -71,7 +71,7 @@ router.staticHandler = function (filename) {
71 71 return;
72 72 }
73 73
74   - //sys.puts("loading " + filename + "...");
  74 + sys.puts("loading " + filename + "...");
75 75 readFile(filename, encoding, function (err, data) {
76 76 if (err) {
77 77 sys.puts("Error loading " + filename);
@@ -82,7 +82,7 @@ router.staticHandler = function (filename) {
82 82 ];
83 83 headers.push(["Cache-Control", "public"]);
84 84
85   - //sys.puts("static file " + filename + " loaded");
  85 + sys.puts("static file " + filename + " loaded");
86 86 callback();
87 87 }
88 88 });
13 lib/server.js
... ... @@ -1,9 +1,5 @@
1 1 var router = require("./router"),
2 2 url = require("url"),
3   - // aggiunti da michele
4   - sys = require("sys"),
5   - fs = require("fs"),
6   - // fine aggiunta
7 3 qs = require("querystring"),
8 4 Channel = require("./channel").Channel;
9 5
@@ -68,9 +64,6 @@ var handlers = [
68 64 }
69 65
70 66 response.simpleJSON(200, { id: session.id, nick: nick, since: session.since });
71   -
72   - sys.puts(session.id + " " + nick + " join");
73   -
74 67 } },
75 68 { path: "/part", handler: function(channel, request, response) {
76 69 var id = qs.parse(url.parse(request.url).query).id;
@@ -97,12 +90,7 @@ var handlers = [
97 90 channel.query(since, function(messages) {
98 91 session.poke();
99 92 response.simpleJSON(200, { messages: messages });
100   - if (messages[0]['type'] == "msg") {
101   - sys.puts(session.id + " " + messages[0]['nick'] + " " + messages[0]['type'] + " " + messages[0]['text']);
102   - }
103 93 });
104   -
105   -
106 94 } },
107 95 { path: "/send", handler: function(channel, request, response) {
108 96 var query = qs.parse(url.parse(request.url).query),
@@ -122,7 +110,6 @@ var handlers = [
122 110 session.poke();
123 111 var id = channel.appendMessage(session.nick, "msg", text);
124 112 response.simpleJSON(200, { id: id });
125   -
126 113 } }
127 114 ];
128 115
2  readme.md
Source Rendered
@@ -69,7 +69,7 @@ Installation & Demo
69 69
70 70 To install:
71 71
72   - git clone http://github.com/scottgonzalez/node-chat.git
  72 + git clone http://github.com/scottgonzalez/node-chat
73 73
74 74 To run the demo:
75 75

0 comments on commit 6f135cd

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