Permalink
Browse files

removed unused node apps

  • Loading branch information...
1 parent 6e11f04 commit 3d998dde5485a988f50a0fa0088f0f1750633ed8 Bob Nugmanov and Dmitriy Kalinin committed Mar 27, 2013
Showing 523 changed files with 0 additions and 38,621 deletions.
@@ -1,16 +0,0 @@
-var http = require('http');
-var url = require('url');
-
-HOST = null;
-
-var host = process.env.VCAP_APP_HOST || 'localhost';
-var port = process.env.VCAP_APP_PORT || 3000
-
-http.createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/html'});
- res.write('<h1>Hello from the Cloud! ');
- res.write('via: ' + host + ':' + port);
- res.end('</h1>');
-}).listen(port, null);
-
-console.log('Server running at http://' + host + ':' + port + '/');
No changes.
@@ -1,16 +0,0 @@
-var http = require('http');
-var url = require('url');
-
-HOST = null;
-
-var host = process.env.VCAP_APP_HOST || 'localhost';
-var port = process.env.VCAP_APP_PORT || 3000
-
-http.createServer(function (req, res) {
- res.writeHead(200, {'Content-Type': 'text/html'});
- res.write('<h1>Hello from the Cloud! ');
- res.write('via: ' + host + ':' + port);
- res.end('</h1>');
-}).listen(port, null);
-
-console.log('Server running at http://' + host + ':' + port + '/');
@@ -1,20 +0,0 @@
-Foo
-Copyright 2009,2010 Ryan Dahl <ry@tinyclouds.org>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to
-deal in the Software without restriction, including without limitation the
-rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-sell copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
-IN THE SOFTWARE.
@@ -1,4 +0,0 @@
-Demo for node.js http://tinyclouds.org/node
-
-to run
-$ /usr/local/bin/node server.js
View
@@ -1,209 +0,0 @@
-HOST = null; // localhost - foo
-PORT = 8001;
-
-// when the daemon started
-var starttime = (new Date()).getTime();
-
-var mem = process.memoryUsage();
-// every 10 seconds poll for the memory.
-setInterval(function () {
- mem = process.memoryUsage();
-}, 10*1000);
-
-
-var fu = require("./fu"),
- sys = require("sys"),
- url = require("url"),
- qs = require("querystring");
-
-var MESSAGE_BACKLOG = 200,
- SESSION_TIMEOUT = 60 * 1000;
-
-var channel = new function () {
- var messages = [],
- callbacks = [];
-
- this.appendMessage = function (nick, type, text) {
- var m = { nick: nick
- , type: type // "msg", "join", "part"
- , text: text
- , timestamp: (new Date()).getTime()
- };
-
- switch (type) {
- case "msg":
- sys.puts("<" + nick + "> " + text);
- break;
- case "join":
- sys.puts(nick + " join");
- break;
- case "part":
- sys.puts(nick + " part");
- break;
- }
-
- messages.push( m );
-
- while (callbacks.length > 0) {
- callbacks.shift().callback([m]);
- }
-
- while (messages.length > MESSAGE_BACKLOG)
- messages.shift();
- };
-
- this.query = function (since, callback) {
- var matching = [];
- for (var i = 0; i < messages.length; i++) {
- var message = messages[i];
- if (message.timestamp > since)
- matching.push(message)
- }
-
- if (matching.length != 0) {
- callback(matching);
- } else {
- callbacks.push({ timestamp: new Date(), callback: callback });
- }
- };
-
- // clear old callbacks
- // they can hang around for at most 30 seconds.
- setInterval(function () {
- var now = new Date();
- while (callbacks.length > 0 && now - callbacks[0].timestamp > 30*1000) {
- callbacks.shift().callback([]);
- }
- }, 3000);
-};
-
-var sessions = {};
-
-function createSession (nick) {
- if (nick.length > 50) return null;
- if (/[^\w_\-^!]/.exec(nick)) return null;
-
- for (var i in sessions) {
- var session = sessions[i];
- if (session && session.nick === nick) return null;
- }
-
- var session = {
- nick: nick,
- id: Math.floor(Math.random()*99999999999).toString(),
- timestamp: new Date(),
-
- poke: function () {
- session.timestamp = new Date();
- },
-
- destroy: function () {
- channel.appendMessage(session.nick, "part");
- delete sessions[session.id];
- }
- };
-
- sessions[session.id] = session;
- return session;
-}
-
-// interval to kill off old sessions
-setInterval(function () {
- var now = new Date();
- for (var id in sessions) {
- if (!sessions.hasOwnProperty(id)) continue;
- var session = sessions[id];
-
- if (now - session.timestamp > SESSION_TIMEOUT) {
- session.destroy();
- }
- }
-}, 1000);
-
-fu.listen(Number(process.env.VCAP_APP_PORT || PORT), HOST);
-
-fu.get("/", fu.staticHandler("index.html"));
-fu.get("/style.css", fu.staticHandler("style.css"));
-fu.get("/client.js", fu.staticHandler("client.js"));
-fu.get("/jquery-1.4.2.min.js", fu.staticHandler("jquery-1.4.2.min.js"));
-
-
-fu.get("/who", function (req, res) {
- var nicks = [];
- for (var id in sessions) {
- if (!sessions.hasOwnProperty(id)) continue;
- var session = sessions[id];
- nicks.push(session.nick);
- }
- res.simpleJSON(200, { nicks: nicks
- , rss: mem.rss
- });
-});
-
-fu.get("/join", function (req, res) {
- var nick = qs.parse(url.parse(req.url).query).nick;
- if (nick == null || nick.length == 0) {
- res.simpleJSON(400, {error: "Bad nick."});
- return;
- }
- var session = createSession(nick);
- if (session == null) {
- res.simpleJSON(400, {error: "Nick in use"});
- return;
- }
-
- //sys.puts("connection: " + nick + "@" + res.connection.remoteAddress);
-
- channel.appendMessage(session.nick, "join");
- res.simpleJSON(200, { id: session.id
- , nick: session.nick
- , rss: mem.rss
- , starttime: starttime
- });
-});
-
-fu.get("/part", function (req, res) {
- var id = qs.parse(url.parse(req.url).query).id;
- var session;
- if (id && sessions[id]) {
- session = sessions[id];
- session.destroy();
- }
- res.simpleJSON(200, { rss: mem.rss });
-});
-
-fu.get("/recv", function (req, res) {
- if (!qs.parse(url.parse(req.url).query).since) {
- res.simpleJSON(400, { error: "Must supply since parameter" });
- return;
- }
- var id = qs.parse(url.parse(req.url).query).id;
- var session;
- if (id && sessions[id]) {
- session = sessions[id];
- session.poke();
- }
-
- var since = parseInt(qs.parse(url.parse(req.url).query).since, 10);
-
- channel.query(since, function (messages) {
- if (session) session.poke();
- res.simpleJSON(200, { messages: messages, rss: mem.rss });
- });
-});
-
-fu.get("/send", function (req, res) {
- var id = qs.parse(url.parse(req.url).query).id;
- var text = qs.parse(url.parse(req.url).query).text;
-
- var session = sessions[id];
- if (!session || !text) {
- res.simpleJSON(400, { error: "No such session id" });
- return;
- }
-
- session.poke();
-
- channel.appendMessage(session.nick, "msg", text);
- res.simpleJSON(200, { rss: mem.rss });
-});
Oops, something went wrong.

0 comments on commit 3d998dd

Please sign in to comment.