aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/webTorrentNode.js
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-01-31 11:23:52 +0100
committerChocobozzz <florian.bigard@gmail.com>2016-01-31 11:23:52 +0100
commitc45f7f84001c2731909db04dd82e1c1f290386eb (patch)
treeb7e57420a1f65dfbbacc1a532bf489c9bea6125d /lib/webTorrentNode.js
parentcda021079ff455cc0fd0eb95a5395fa808ab63d1 (diff)
downloadPeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.tar.gz
PeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.tar.zst
PeerTube-c45f7f84001c2731909db04dd82e1c1f290386eb.zip
Infile code reorganization
Diffstat (limited to 'lib/webTorrentNode.js')
-rw-r--r--lib/webTorrentNode.js27
1 files changed, 14 insertions, 13 deletions
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 @@
10 10
11 var host = config.get('webserver.host') 11 var host = config.get('webserver.host')
12 var port = config.get('webserver.port') 12 var port = config.get('webserver.port')
13
14 var nodeKey = 'webtorrentnode' + port 13 var nodeKey = 'webtorrentnode' + port
15 var processKey = 'webtorrent' + port 14 var processKey = 'webtorrent' + port
16
17 ipc.config.silent = true 15 ipc.config.silent = true
18 ipc.config.id = nodeKey 16 ipc.config.id = nodeKey
19 17
20 var webtorrentnode = {} 18 var webtorrentnode = {
21 19 add: add,
22 // Useful for beautiful tests 20 app: null, // Pid of the app
23 webtorrentnode.silent = false 21 create: create,
24 22 remove: remove,
25 // Useful to kill it 23 seed: seed,
26 webtorrentnode.app = null 24 silent: false // Useful for beautiful tests
25 }
27 26
28 webtorrentnode.create = function (options, callback) { 27 function create (options, callback) {
29 if (typeof options === 'function') { 28 if (typeof options === 'function') {
30 callback = options 29 callback = options
31 options = {} 30 options = {}
@@ -75,7 +74,7 @@
75 ipc.server.start() 74 ipc.server.start()
76 } 75 }
77 76
78 webtorrentnode.seed = function (path, callback) { 77 function seed (path, callback) {
79 var extension = pathUtils.extname(path) 78 var extension = pathUtils.extname(path)
80 var basename = pathUtils.basename(path, extension) 79 var basename = pathUtils.basename(path, extension)
81 var data = { 80 var data = {
@@ -104,7 +103,7 @@
104 ipc.server.broadcast(processKey + '.seed', data) 103 ipc.server.broadcast(processKey + '.seed', data)
105 } 104 }
106 105
107 webtorrentnode.add = function (magnetUri, callback) { 106 function add (magnetUri, callback) {
108 var data = { 107 var data = {
109 _id: magnetUri, 108 _id: magnetUri,
110 args: { 109 args: {
@@ -131,7 +130,7 @@
131 ipc.server.broadcast(processKey + '.add', data) 130 ipc.server.broadcast(processKey + '.add', data)
132 } 131 }
133 132
134 webtorrentnode.remove = function (magnetUri, callback) { 133 function remove (magnetUri, callback) {
135 var data = { 134 var data = {
136 _id: magnetUri, 135 _id: magnetUri,
137 args: { 136 args: {
@@ -156,5 +155,7 @@
156 ipc.server.broadcast(processKey + '.remove', data) 155 ipc.server.broadcast(processKey + '.remove', data)
157 } 156 }
158 157
158 // ---------------------------------------------------------------------------
159
159 module.exports = webtorrentnode 160 module.exports = webtorrentnode
160})() 161})()