diff --git a/index.js b/index.js index 0e90234..5f3c44e 100644 --- a/index.js +++ b/index.js @@ -1,8 +1 @@ -var acequia = require('./lib/acequia'); - -var start = function () { - var acequiaServer = acequia.createServer(); - acequiaServer.start(); -}; - -start(); \ No newline at end of file +module.exports = require('./lib/acequia'); \ No newline at end of file diff --git a/lib/acequia.js b/lib/acequia.js index c7cbccc..82dc491 100644 --- a/lib/acequia.js +++ b/lib/acequia.js @@ -28,10 +28,6 @@ var acequiaClients = null; function AcequiaServer(options) { - if (typeof(options) === "undefined") { - options = {}; - } - this.options = Object.extend({ ipAddress: "0.0.0.0", oscPort: 9090, @@ -60,7 +56,7 @@ AcequiaServer.prototype.start = function () { this.wsServer = this.createWSServer(); } - if (this.tcpPort) { + if (this.options.tcpPort) { this.tcpServer = this.createTCPServer(); } }; @@ -159,7 +155,7 @@ AcequiaServer.prototype.createTCPServer = function () { } }); - tcpServer.listen(this.options.tcpServer, this.options.ipAddress); + tcpServer.listen(this.options.tcpPort, this.options.ipAddress); return tcpServer; }; @@ -193,7 +189,7 @@ AcequiaServer.prototype.createWSServer = function () { logger.debug(" WS Server is listening on [%s:%s]", this.address().address, this.address().port); }); - httpServer.listen(this.wsPort); + httpServer.listen(this.options.wsPort); // Create the socket io server and attach it to the httpServer wsServer = require('socket.io').listen(httpServer); diff --git a/lib/genclient.js b/lib/genclient.js index 2f39505..7d95572 100644 --- a/lib/genclient.js +++ b/lib/genclient.js @@ -13,7 +13,7 @@ var concatenateClientFiles = function () { var buffer, code = "", fd, stats, i, size = 0, file, files = ["msg.js", "acequiaClient.js"]; for (i in files) { - file = process.cwd() + "/lib/" + files[i]; + file = __dirname + "/" + files[i]; stats = fs.statSync(file); buffer = new Buffer(stats.size); diff --git a/package.json b/package.json index bd5672f..063bfeb 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name" : "acequia" , "version" : "0.1.0" , "description":"Message router for node supporting multiple protocols" -, "main": "index.js" +, "main": "server.js" , "preferGlobal": "true" , "directories": {"lib": "./lib" } , "scripts": { "start": "node ." } diff --git a/server.js b/server.js new file mode 100644 index 0000000..c604352 --- /dev/null +++ b/server.js @@ -0,0 +1,8 @@ +var acequia = require('./lib/acequia'); + +var start = function () { + var acequiaServer = acequia.createServer(); + acequiaServer.start(); +}; + +start();