diff --git a/lib/acequia.js b/lib/acequia.js index 8bed100..f1379a7 100644 --- a/lib/acequia.js +++ b/lib/acequia.js @@ -38,6 +38,7 @@ function AcequiaServer(options) { , tcpPort: 9092 , timeout: 600000 , express_app: null + , httpServer: null , minify_client: true , enableDiscovery: true }, options || {}); @@ -254,17 +255,22 @@ AcequiaServer.prototype.createTCPServer = function () { */ AcequiaServer.prototype.createWSServer = function () { var clientCode, io, app; - + if (!clientCode) { // Generate the client code clientCode = require("./genclient").generateClientCode(); } if (!this.options.express_app) { - this.options.express_app = express.createServer(); - this.options.express_app.listen(this.options.wsPort); - } + this.options.express_app = express(); + // this.options.express_app.listen(this.options.wsPort); + } + if (!this.options.httpServer) { + this.options.httpServer = http.createServer(this.options.express_app); + this.options.httpServer.listen(this.options.wsPort); + } app = this.options.express_app; + httpServer = this.options.httpServer; // Add the acequiaServer instance to the web app, so it has acess to its // options @@ -318,7 +324,7 @@ AcequiaServer.prototype.createWSServer = function () { logger.debug(" WS Server is listening on [%s:%s]", this.address().address, this.address().port); }); - io = require('socket.io').listen(app); + io = require('socket.io').listen(httpServer); io.configure(function () { io.enable('browser client minification'); // send minified client diff --git a/package.json b/package.json index 8096627..f62b530 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ , "engines": { "node": ">=0.6" } , "dependencies" : { "log4js" : ">=0.4.1" - , "express": "2.5.9" + , "express": "3.1.x" , "socket.io": ">=0.9.6" , "socket.io-client":">=0.9.6" , "uglify-js": ">=1.2.5"