Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

replace socket.io with smith.io

  • Loading branch information...
commit c3d84fe4d697a112e1ce4fb6056451681045c87d 1 parent e4446d0
@cadorn cadorn authored
View
1  .npmignore
@@ -19,6 +19,5 @@ support/connect/support/expresso
support/connect/support/less
support/connect/support/sass
support/connect/support/coffee-script
-support/socket.io/support/expresso
support/gnu-builds
*.psd
View
5 README.md
@@ -133,7 +133,8 @@ Main projects that we use as building blocks:
* [async.js] by [fjakobs]
* [jsDAV] by [mikedeboer]
* [connect] by [senchalabs](http://github.com/senchalabs)
- * [socket.io] by [LearnBoost](http://github.com/LearnBoost)
+ * [engine.io] by [LearnBoost](http://github.com/LearnBoost)
+ * [smith.io](http://github.com/c9/smith.io) by [creationix](http://github.com/creationix) & [cadorn](http://github.com/cadorn)
* [ace](http://github.com/ajaxorg/ace) by [fjakobs]
* [apf](http://www.ajax.org) by [ajax.org]
* and of course [Node.JS]!
@@ -147,7 +148,7 @@ Thanks to all developers and contributors of these projects!
[async.js]: http://github.com/fjakobs/async.js
[jsDAV]: http://github.com/mikedeboer/jsdav
[connect]: http://github.com/senchalabs/connect
-[socket.io]: http://github.com/LearnBoost/Socket.IO-node.git
+[engine.io]: http://github.com/LearnBoost/engine.io
[requireJS]: http://requirejs.org/
[Node.JS]: http://nodejs.org/
View
15 configs/default.js
@@ -45,6 +45,7 @@ var config = [
"./../plugins-client/lib.treehugger",
"./../plugins-client/lib.v8debug",
"./../plugins-client/lib.requirejs",
+ "./../plugins-client/lib.smith.io",
// server plugins
{
packagePath: "./cloud9.sandbox",
@@ -57,8 +58,12 @@ var config = [
packagePath: "./cloud9.core",
debug: false,
fsUrl: fsUrl,
+ smithIo: {
+ host: host,
+ port: port,
+ prefix: "/smith.io/server"
+ },
hosted: false,
- socketIoTransports: ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"],
bundledPlugins: [
"helloworld"
],
@@ -146,12 +151,18 @@ var config = [
packagePath: "./cloud9.fs",
urlPrefix: fsUrl
},
+ {
+ packagePath: "smith.io/server-plugin",
+ clientRoute: "/static/smith.io/client.js",
+ messageRoute: "/smith.io/server"
+ },
"./cloud9.socket",
{
packagePath: "connect-architect/connect.session",
key: "cloud9.sid." + port,
secret: "v1234"
- }, {
+ },
+ {
packagePath: "connect-architect/connect.session.file",
sessionsPath: __dirname + "/../.sessions"
},
View
4 configs/local.js
@@ -1,12 +1,14 @@
var plugins = require("./default");
+/*
plugins.forEach(function(plugin) {
if (plugin.packagePath) {
if (/\/cloud9.core$/.test(plugin.packagePath)) {
- plugin.socketIoTransports = ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"];
+
}
}
});
+*/
module.exports = plugins;
View
5 configs/packed.js
@@ -1,15 +1,16 @@
var plugins = require("./default");
+/*
plugins.forEach(function(plugin) {
if (plugin.packagePath) {
if (/\/cloud9.core$/.test(plugin.packagePath)) {
- plugin.socketIoTransports = ["websocket", "htmlfile", "xhr-multipart", "xhr-polling"];
}
}
});
+*/
plugins = plugins.filter(function(plugin) {
- // returns false of any of these plugins are detected; lib.packed will emit them
+ // returns false if any of these plugins are detected; lib.packed will emit them
return !(/\/plugins-client\/cloud9.core$/.test(plugin) ||
/\/plugins-client\/lib.ace$/.test(plugin) ||
/\/plugins-client\/lib.apf$/.test(plugin) ||
View
11 package.json
@@ -27,7 +27,12 @@
"async": "0.1.21",
"netutil": "0.0.1",
"architect": "0.1.4",
- "connect-architect": "0.0.3"
+ "connect-architect": "0.0.3",
+
+ "smith.io": "0.0.5",
+ "smith": "0.1.7",
+ "events": "0.5.0",
+ "engine.io-client": "0.2.0"
},
"devDependencies": {
@@ -48,8 +53,8 @@
"vfs": ["npm", "https://github.com/c9/vfs/tarball/be43f8b32f9b1c69923dd85ec9be7eb6836bbb29"],
"vfs-architect":["npm", "https://github.com/c9/vfs-architect/tarball/43bd19b9e7b2ddb95bdc1116143ce7fb22c6a5d3"],
"treehugger": ["npm", "https://github.com/ajaxorg/treehugger/tarball/46f9d8ffdb159a2c206d41ed6ad877f471bb1e2f"],
- "socket.io": ["npm", "https://github.com/ajaxorg/socket.io/tarball/7aa252bab49e6bbc314dc2678b108b6e0876007a"],
- "socket.io-client": ["npm", "https://github.com/ajaxorg/socket.io-client/tarball/35f0763ffcaa7ccc3c664460667577e77da82b10"]
+ "msgpack-js": ["npm", "https://github.com/creationix/msgpack-js-browser/tarball/e6dc213cb602d5a8fb402520d7841d2664cd10e9"],
+ "extendables": ["url", "https://raw.github.com/Gozala/extendables/v0.2.0/extendables.js"]
},
"repository" : {
View
213 plugins-client/cloud9.core/www/core/ide.js
@@ -9,6 +9,8 @@ var ide; //Global on purpose!!!!
define(function(require, exports, module) {
var Document = require("core/document");
var util = require("core/util");
+ require("engine.io");
+ var SMITH_IO = require("smith.io");
ide = new apf.Class().$init();
@@ -78,182 +80,83 @@ define(function(require, exports, module) {
ide.start();
- // fire up the socket connection:
- var options = {
- "remember transport": false,
- transports: window.cloud9config.socketIoTransports,
- reconnect: false,
- resource: window.cloud9config.socketIoUrl,
- "connect timeout": 500,
- "try multiple transports": true,
- "transport options": {
- "xhr-polling": {
- timeout: 60000
- },
- "jsonp-polling": {
- timeout: 60000
- }
+ // fire up the socket connection:
+ if (window.cloud9config.debug) console.info("Connecting", JSON.parse(window.cloud9config.smithIo));
+
+ SMITH_IO.connect(JSON.parse(window.cloud9config.smithIo), function(err, connection) {
+
+ if (err) {
+ console.error(err);
+ return;
}
- };
- var retries = 0;
- ide.socketConnect = function() {
- // NOTE: This is a workaround for an init bug in socket.io
- // @see https://github.com/LearnBoost/socket.io-client/issues/390
- if (!ide.socket.socket.transport) {
- // Try and connect until we succeed.
- // NOTE: This may log a connection error to the error console but will recover gracefully and eventually connect.
- ide.socketDisconnect();
- } else {
- retries = 0;
-
+ connection.on("connect", function() {
+ if (window.cloud9config.debug) console.info("Connected");
ide.connecting = true;
- ide.socket.json.send({
+ ide.send = function(msg) {
+ connection.send(msg);
+ };
+ ide.send({
command: "attach",
sessionId: ide.sessionId,
workspaceId: ide.workspaceId
});
- }
- };
+ });
+ connection.on("disconnect", function(reason) {
+ if (window.cloud9config.debug) console.info("Disconnected");
+ ide.connected = false;
+ ide.send = function(msg) {
+ console.error("Cannot send message. Not connected any more! ACTION: You need to respect the IDE `socketConnect/socketDisconnect` events.", msg);
+ };
+ ide.dispatchEvent("socketDisconnect");
+ });
- ide.socketDisconnect = function() {
- //Do Nothing
- };
-
- ide.reconnectIfNeeded = function(){
- var sock = ide.socket.socket;
- if (!sock.connected && !sock.connecting && !sock.reconnecting) { //ide.loggedIn
- retries++;
- if (retries < 10 || retries < 60 && retries % 10 == 0 || retries % 50 == 0) {
- sock.disconnect();
- sock.remainingTransports = null;
- sock.connect();
-
- if (retries == 5) {
- ide.dispatchEvent("socketDisconnect");
- ide.connected = false;
+ connection.on("message", function(message) {
+ if (typeof message == "string") {
+ try {
+ message = JSON.parse(message);
+ }
+ catch(e) {
+ window.console && console.error("Error parsing socket message", e, "message:", message);
+ return;
}
}
- }
- }
-
- ide.socketMessage = function(message) {
- if (typeof message == "string") {
- try {
- message = JSON.parse(message);
- }
- catch(e) {
- window.console && console.error("Error parsing socket message", e, "message:", message);
- return;
- }
- }
-
- if (message.type == "attached") {
- ide.connecting = false;
- ide.connected = true;
- ide.dispatchEvent("socketConnect"); //This is called too often!!
- }
- if (message.type === "error") {
- // TODO: Don't display all errors?
- if (ide.dispatchEvent("showerrormessage", message) !== false) {
- util.alert(
- "Error on server",
- "Received following error from server:",
- JSON.stringify(message.message)
- );
+ if (message.type == "attached") {
+ ide.connecting = false;
+ ide.connected = true;
+ ide.dispatchEvent("socketConnect");
}
- }
- ide.dispatchEvent("socketMessage", {
- message: message
- });
- };
-
- // for unknown reasons io is sometimes undefined
- try {
- ide.socket = io.connect(null, options);
-
- var transportReadyHandler = function(){
- setInterval(ide.reconnectIfNeeded, 100);
-
- ide.socket.removeListener("connect_failed", transportReadyHandler);
- ide.socket.removeListener("error", transportReadyHandler);
- ide.socket.removeListener("connecting", transportReadyHandler);
- }
-
- ide.socket.on("connect_failed", transportReadyHandler);
- ide.socket.on("error", transportReadyHandler);
- ide.socket.on("connecting", transportReadyHandler);
-
- ide.socket.on("message", ide.socketMessage);
- ide.socket.on("connect", ide.socketConnect);
- ide.socket.on("disconnect", ide.socketDisconnect);
- }
- catch (e) {
- util.alert(
- "Error starting up",
- "Error starting up the IDE",
- "There was an error starting up the IDE.<br>Please clear your browser cache and reload the page.",
- function() {
- window.location.reload();
- }
- );
-
- var socketIoScriptEl = Array.prototype.slice.call(
- document.getElementsByTagName("script")).filter(function(script) {
- return script.src && script.src.indexOf("socket.io.js") >= 0;
+ if (message.type === "error") {
+ // TODO: Don't display all errors?
+ if (ide.dispatchEvent("showerrormessage", message) !== false) {
+ util.alert(
+ "Error on server",
+ "Received following error from server:",
+ JSON.stringify(message.message)
+ );
+ }
}
- )[0];
- var status;
- if (socketIoScriptEl) {
- apf.ajax(socketIoScriptEl.src, {
- callback: function(data, state, extra) {
- try {
- status = parseInt(extra.http.status, 10);
- } catch(ex) {}
-
- apf.dispatchEvent("error", {
- message: "socket.io client lib not loaded",
- error: {
- status: status,
- state: state,
- data: data,
- extra: extra
- }
- });
- }
- });
- } else {
- apf.dispatchEvent("error", {
- message: "socket.io client lib not loaded",
- error: e
+ ide.dispatchEvent("socketMessage", {
+ message: message
});
- }
- return;
- }
+ });
- this.inited = true;
+ connection.on("away", function() {
+ if (window.cloud9config.debug) console.info("Away");
+ });
+ connection.on("back", function() {
+ if (window.cloud9config.debug) console.info("Back");
+ });
- ide.$msgQueue = [];
- ide.addEventListener("socketConnect", function() {
- while(ide.$msgQueue.length) {
- var q = ide.$msgQueue;
- ide.$msgQueue = [];
- q.forEach(function(msg) {
- ide.socket.json.send(msg);
- });
- }
});
- ide.send = function(msg) {
- if (!ide.socket || !ide.socket.socket.connected) {
- ide.$msgQueue.push(msg);
- return;
- }
+ this.inited = true;
- ide.socket.json.send(msg);
+ ide.send = function(msg) {
+ console.error("Cannot send message. Not connected yet! ACTION: You need to respect the IDE `socketConnect/socketDisconnect` events.", msg);
};
ide.getActivePageModel = function() {
View
14 plugins-client/ext.offline/offline.js
@@ -20,18 +20,6 @@ module.exports = ext.register("ext/offline/offline", {
offlineStartup : 0,
/**
- * Test method for going offline/online
- * @param {Boolean} online If the request is to go online or not
- */
- test : function(online){
- ide.testOffline = online ? 2 : 1;
- if (online)
- ide.socket.socket.connect();
- else
- ide.socket.socket.disconnect();
- },
-
- /**
* Init method to create the offline logic
*/
init : function(){
@@ -103,7 +91,7 @@ module.exports = ext.register("ext/offline/offline", {
ide.dispatchEvent("afteroffline"); // Faking offline startup
// We may miss the first socketConnect event
- if (ide.socket.socket.connected)
+ if (ide.connected)
offline.goOnline();
else
offline.goOffline();
View
55 plugins-client/lib.smith.io/lib.js
@@ -0,0 +1,55 @@
+
+const PATH = require("path");
+const MAPPINGS = require("mappings").for(PATH.join(__dirname, "../.."));
+
+module.exports = function setup(options, imports, register) {
+
+ imports.static.addStatics([{
+ path: PATH.dirname(require.resolve("engine.io-client/dist/engine.io.js")),
+ mount: "/engine.io/lib",
+ rjs: {
+ "engine.io": "/engine.io/lib/engine.io",
+ "smith.io": "/smith.io/client"
+ }
+ }]);
+
+ imports.static.addStatics([{
+ path: PATH.dirname(require.resolve("smith")),
+ mount: "/smith/lib",
+ rjs: {
+ "smith": "/smith/lib/smith",
+ }
+ }]);
+
+ imports.static.addStatics([{
+ path: PATH.dirname(require.resolve("events/events")),
+ mount: "/events/lib",
+ rjs: {
+ "events": "/events/lib/events",
+ }
+ }]);
+
+ imports.static.addStatics([{
+ path: PATH.dirname(require.resolve("msgpack-js")),
+ mount: "/msgpack-js/lib",
+ rjs: {
+ "msgpack-js": "/msgpack-js/lib/msgpack",
+ }
+ }]);
+
+ imports.static.addStatics([{
+ path: MAPPINGS.resolve("extendables"),
+ mount: "/raw.github.com/Gozala/extendables/v0.2.0/extendables.js",
+ rjs: {
+ "extendables": "/"
+ },
+ router: function(req, res) {
+ req.url = "/response-body";
+ res.setHeader("Content-Type", "application/javascript");
+ }
+ }]);
+
+ register(null, {
+ "client.v8debug": {}
+ });
+};
View
10 plugins-client/lib.smith.io/package.json
@@ -0,0 +1,10 @@
+{
+ "name": "cloud9.client.smith.io",
+ "version": "0.0.1",
+ "main": "lib.js",
+ "private": true,
+ "plugin": {
+ "provides": [],
+ "consumes": ["static"]
+ }
+}
View
7 plugins-server/cloud9.core/ide-plugin.js
@@ -20,8 +20,6 @@ module.exports = function setup(options, imports, register) {
var staticPrefix = imports.static.getStaticPrefix();
var workerPrefix = imports.static.getWorkerPrefix() || "/static";
- var socketUrl = options.socketUrl || "/socket.io";
-
var ide;
var serverPlugins = {};
@@ -50,8 +48,7 @@ module.exports = function setup(options, imports, register) {
settingsPath: settingsPath,
davPrefix: baseUrl + "/workspace",
projectName: options.projectName || "",
- socketIoUrl: socketUrl.replace(/^\//, ""),
- socketIoTransports: options.socketIoTransports,
+ smithIo: options.smithIo,
baseUrl: baseUrl,
debug: (options.debug === true) ? true : false,
workerUrl: workerPrefix,
@@ -114,7 +111,7 @@ module.exports = function setup(options, imports, register) {
return ide;
},
getSocketUrl: function() {
- return socketUrl;
+ console.error(new Error("ide.getSocketUrl() is DEPRECATED").stack);
},
getBaseUrl: function() {
return baseUrl;
View
9 plugins-server/cloud9.core/ide.js
@@ -21,8 +21,7 @@ var Ide = module.exports = function(options) {
assert(options.workspaceId, "option 'workspaceId' is required");
assert(options.workspaceDir, "option 'workspaceDir' is required");
assert(options.requirejsConfig, "option 'requirejsConfig' is required");
- assert(options.socketIoUrl, "option 'socketIoUrl' is required");
- assert(options.socketIoTransports, "option 'socketIoTransports' is required");
+ assert(options.smithIo, "option 'smithIo' is required");
// assert.equal(options.workspaceDir.charAt(0), "/", "option 'workspaceDir' must be an absolute path");
var staticUrl = options.staticUrl || "/static";
@@ -35,8 +34,7 @@ var Ide = module.exports = function(options) {
this.options = {
workspaceDir: this.workspaceDir,
mountDir: options.mountDir || this.workspaceDir,
- socketIoUrl: options.socketIoUrl,
- socketIoTransports: options.socketIoTransports,
+ smithIo: options.smithIo,
davPrefix: options.davPrefix,
davPlugins: options.davPlugins || exports.DEFAULT_DAVPLUGINS,
debug: (options.debug === true) ? true : false,
@@ -131,8 +129,7 @@ util.inherits(Ide, EventEmitter);
debug: _self.options.debug,
workerUrl: workerUrl,
staticUrl: staticUrl,
- socketIoUrl: _self.options.socketIoUrl,
- socketIoTransports: _self.options.socketIoTransports,
+ smithIo: JSON.stringify(_self.options.smithIo),
sessionId: req.sessionID, // set by connect
uid: req.session.uid || req.session.anonid || 0,
pid: _self.options.pid || process.pid || 0,
View
2  plugins-server/cloud9.core/user.js
@@ -141,7 +141,7 @@ User.VISITOR_PERMISSIONS = {
// pass a lambda to enable socket.io ACK
if (client)
- client.send(JSON.stringify(error), function() {});
+ client.send(error, function() {});
else
this.broadcast(error);
};
View
4 plugins-server/cloud9.core/view/ide.tmpl.html
@@ -16,7 +16,6 @@
<link rel="stylesheet" type="text/css" href="[%staticUrl%]/ext/main/style/style.css" />
[%loadedDetectionScript%]
- <script type="text/javascript" src="/[%socketIoUrl%]/socket.io.js"></script>
<script type="text/javascript" src="[%staticUrl%]/require.js"></script>
[%scripts%]
<script type="text/javascript">
@@ -37,8 +36,7 @@
version: <%version%>,
workerUrl: "[%workerUrl%]",
staticUrl: "[%staticUrl%]",
- socketIoUrl: <%socketIoUrl%>,
- socketIoTransports: <%socketIoTransports%>,
+ smithIo: <%smithIo%>,
hosted: [%hosted%],
local: <%local%>,
env: <%env%>,
View
4 plugins-server/cloud9.core/workspace.js
@@ -74,12 +74,12 @@ var Workspace = module.exports = function(ide) {
this.send = function(msg, replyTo, scope) {
if (replyTo)
msg.sid = replyTo.sid;
- this.ide.broadcast(JSON.stringify(msg), scope);
+ this.ide.broadcast(msg, scope);
};
this.sendError = function(error, client) {
if (client)
- client.send(JSON.stringify(error));
+ client.send(error);
else
this.ide.broadcast(error);
};
View
7 plugins-server/cloud9.socket/package.json
@@ -4,17 +4,14 @@
"main": "socket-ext.js",
"private": true,
- "dependencies": {
- "socket.io": "0.8.x"
- },
-
"plugin": {
"provides": ["workspace-socket"],
"consumes": [
"http",
"ide",
"session",
- "workspace-permissions"
+ "workspace-permissions",
+ "smith.transport.server"
]
}
}
View
86 plugins-server/cloud9.socket/socket-ext.js
@@ -1,33 +1,77 @@
"use strict";
-var Socket = require("./socket");
+var ERROR = require("http-error");
module.exports = function setup(options, imports, register) {
- var ide = imports.ide.getServer();
- var session = imports.session;
- var permissions = imports["workspace-permissions"];
-
- var socket = new Socket(session, session.getKey(), imports.ide.getSocketUrl());
- socket.listen(imports.http.getServer());
- socket.on("attach", function(client, message) {
- var uid = message.session.uid || message.session.anonid;
- permissions.getPermissions(uid, message.workspaceId, "cloud9.socket.socket-ext", function(err, userPermissions) {
- if (err) {
- client.send(JSON.stringify(err.toJSON
- ? err.toJSON()
- : {
- "type": "error",
- "code": err.code || 500,
- "message": err.message || err
- })
- );
+
+ var IDE = imports.ide.getServer();
+ var SESSION = imports.session;
+ var PERMISSIONS = imports["workspace-permissions"];
+ var TRANSPORT = imports["smith.transport.server"];
+
+
+ TRANSPORT.on("connect", function(connection) {
+
+ console.log("Connected:", connection.id);
+
+ connection.once("disconnect", function(reason) {
+ console.log("Disconnected:", connection.id, reason);
+ });
+
+ connection.on("message", function(message) {
+
+ if (message.command === "attach" && typeof message.workspaceId !== "undefined") {
+
+ getSession(message.sessionId, function(err, session) {
+ if (err) {
+ return connection.send({
+ "type": "error",
+ "code": err.code,
+ "message": err.message
+ });
+ }
+
+ message.session = session;
+ var uid = session.uid || session.anonid;
+ PERMISSIONS.getPermissions(uid, message.workspaceId, "cloud9.socket", function(err, userPermissions) {
+ if (err) {
+ connection.send(err.toJSON ? err.toJSON() : {
+ "type": "error",
+ "code": err.code || 500,
+ "message": err.message || err
+ });
+ }
+
+ IDE.addUser(uid, userPermissions);
+ IDE.addClientConnection(uid, connection, message);
+ });
+ });
}
+ });
- ide.addUser(uid, userPermissions);
- ide.addClientConnection(uid, client, message);
+ connection.on("away", function() {
+ console.log("Away:", connection.id);
+ });
+
+ connection.on("back", function() {
+ console.log("Back:", connection.id);
});
});
+
+ function getSession(sessionId, callback) {
+ SESSION.get(sessionId, function(err, session) {
+ if (err)
+ return callback(new ERROR.InternalServerError(err));
+
+ if (!session || !(session.uid || session.anonid))
+ return callback(new ERROR.Unauthorized("Session ID missing"));
+
+ return callback(null, session);
+ });
+ };
+
+
register(null, {
"workspace-socket": {}
});
View
95 plugins-server/cloud9.socket/socket.js
@@ -1,95 +0,0 @@
-"use strict";
-
-var EventEmitter = require("events").EventEmitter;
-var util = require("util");
-var socketIo = require("socket.io");
-var connectUtil = require("connect/lib/utils");
-var error = require("http-error");
-
-var Socket = module.exports = function(sessionStore, sessionKey, mountDir) {
- EventEmitter.call(this);
-
- this.mountDir = mountDir || "/socket.io";
- this.sessionKey = sessionKey;
- this.sessionStore = sessionStore;
-};
-
-util.inherits(Socket, EventEmitter);
-
-(function() {
-
- this.listen = function(server) {
- var io = this.io = socketIo.listen(server, {
- resource: this.mountDir
- });
-
- io.enable("browser client minification");
- io.set("log level", 0);
- io.disable("destroy upgrade");
- io.set("transports", ["websocket", "htmlfile", "xhr-polling"]);
- io.set("authorization", this._auth.bind(this));
-
- io.sockets.on("connection", this._onConnection.bind(this));
- };
-
- this._auth = function(req, callback) {
- if (!req.headers.cookie)
- return callback(new Error("Session ID missing"));
-
- var cookies = connectUtil.parseCookie(req.headers.cookie);
- var sessionId = cookies[this.sessionKey];
-
- if (!sessionId)
- return callback(new Error("Session ID missing"));
-
- this._getSession(sessionId, function(err, session) {
- callback(err, !err);
- });
- };
-
- this._onConnection = function(client) {
- var self = this;
- client.on("message", function onMessage(message) {
- if (typeof message == "string") {
- //console.warn("got non JSON message!", message);
- try {
- message = JSON.parse(message);
- }
- catch (ex) {
- return console.error(ex);
- }
- }
-
- if (message.command !== "attach")
- return;
-
- client.removeListener("attach", onMessage);
-
- self._getSession(message.sessionId, function(err, session) {
- if (err) {
- return client.send(JSON.stringify({
- "type": "error",
- "code": err.code,
- "message": err.message
- }));
- }
-
- message.session = session;
- self.emit("attach", client, message);
- });
- });
- };
-
- this._getSession = function(sessionId, callback) {
- this.sessionStore.get(sessionId, function(err, session) {
- if (err)
- return callback(new error.InternalServerError(err));
-
- if (!session || !(session.uid || session.anonid))
- return callback(new error.Unauthorized("Session ID missing"));
-
- return callback(null, session);
- });
- };
-
-}).call(Socket.prototype);
View
26 plugins-server/cloud9.static/static.js
@@ -4,27 +4,39 @@ var connect = require("connect");
module.exports = function startup(options, imports, register) {
var rjs = {};
- var prefix = options.prefix || "/static";
+ var prefix = options.bindPrefix || options.prefix || "/static";
var workerPrefix = options.workerPrefix || "/static";
var staticServer = connect.createServer();
- imports.connect.useMain(options.bindPrefix || prefix, staticServer)
+ imports.connect.useMain(prefix, staticServer);
register(null, {
"static": {
addStatics: function(statics) {
- for (var i = 0; i < statics.length; i++) {
- var s = statics[i];
-// console.log("MOUNT", s.mount, s.path, prefix);
+ statics.forEach(function(s) {
- staticServer.use(s.mount, connect.static(s.path));
+// console.log("MOUNT", prefix, s.mount, s.path);
+
+ if (s.router) {
+
+ var server = connect.static(s.path);
+ staticServer.use(s.mount, function(req, res, next) {
+ s.router(req, res);
+ server(req, res, next);
+ });
+
+ } else {
+
+ staticServer.use(s.mount, connect.static(s.path));
+
+ }
var libs = s.rjs || {};
for (var name in libs) {
rjs[name] = join(prefix, libs[name]);
}
- }
+ });
},
getRequireJsPaths: function() {
View
7 test/blacklist.txt
@@ -4,13 +4,6 @@
./node_modules/sinon/test/sinon/util/fake_server_test.js
./node_modules/sinon/test/sinon/util/fake_server_with_clock_test.js
./node_modules/sinon/test/sinon/util/fake_xml_http_request_test.js
-./node_modules/socket.io/node_modules/redis/tests/re_sub_test.js
-./node_modules/socket.io/node_modules/redis/tests/reconnect_test.js
-./node_modules/socket.io/node_modules/redis/tests/sub_quit_test.js
-./node_modules/socket.io-client/node_modules/socket.io/node_modules/redis/eval_test.js
-./node_modules/socket.io-client/node_modules/socket.io/node_modules/redis/simple_test.js
-./node_modules/socket.io-client/node_modules/socket.io/node_modules/redis/tests/reconnect_test.js
-./node_modules/socket.io-client/node_modules/socket.io/node_modules/redis/tests/sub_quit_test.js
./node_modules/treehugger/lib/treehugger/js/parse_test.js
./node_modules/treehugger/lib/treehugger/js/uglifyparser_test.js
./node_modules/sinon/test/sinon_test.js
Please sign in to comment.
Something went wrong with that request. Please try again.