From c45f7f84001c2731909db04dd82e1c1f290386eb Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 31 Jan 2016 11:23:52 +0100 Subject: Infile code reorganization --- lib/webTorrentNode.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'lib/webTorrentNode.js') diff --git a/lib/webTorrentNode.js b/lib/webTorrentNode.js index 8827c68c5..69fa6b012 100644 --- a/lib/webTorrentNode.js +++ b/lib/webTorrentNode.js @@ -10,22 +10,21 @@ var host = config.get('webserver.host') var port = config.get('webserver.port') - var nodeKey = 'webtorrentnode' + port var processKey = 'webtorrent' + port - ipc.config.silent = true ipc.config.id = nodeKey - var webtorrentnode = {} - - // Useful for beautiful tests - webtorrentnode.silent = false - - // Useful to kill it - webtorrentnode.app = null + var webtorrentnode = { + add: add, + app: null, // Pid of the app + create: create, + remove: remove, + seed: seed, + silent: false // Useful for beautiful tests + } - webtorrentnode.create = function (options, callback) { + function create (options, callback) { if (typeof options === 'function') { callback = options options = {} @@ -75,7 +74,7 @@ ipc.server.start() } - webtorrentnode.seed = function (path, callback) { + function seed (path, callback) { var extension = pathUtils.extname(path) var basename = pathUtils.basename(path, extension) var data = { @@ -104,7 +103,7 @@ ipc.server.broadcast(processKey + '.seed', data) } - webtorrentnode.add = function (magnetUri, callback) { + function add (magnetUri, callback) { var data = { _id: magnetUri, args: { @@ -131,7 +130,7 @@ ipc.server.broadcast(processKey + '.add', data) } - webtorrentnode.remove = function (magnetUri, callback) { + function remove (magnetUri, callback) { var data = { _id: magnetUri, args: { @@ -156,5 +155,7 @@ ipc.server.broadcast(processKey + '.remove', data) } + // --------------------------------------------------------------------------- + module.exports = webtorrentnode })() -- cgit v1.2.3