]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - lib/webTorrentNode.js
Update lodash and webtorrent modules
[github/Chocobozzz/PeerTube.git] / lib / webTorrentNode.js
index 8827c68c56b6231b1b381d23c0cc129513ec7728..69fa6b01220a3f3fbb34d336bc592a879f2e3fba 100644 (file)
 
   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 = {
     ipc.server.broadcast(processKey + '.seed', data)
   }
 
-  webtorrentnode.add = function (magnetUri, callback) {
+  function add (magnetUri, callback) {
     var data = {
       _id: magnetUri,
       args: {
     ipc.server.broadcast(processKey + '.add', data)
   }
 
-  webtorrentnode.remove = function (magnetUri, callback) {
+  function remove (magnetUri, callback) {
     var data = {
       _id: magnetUri,
       args: {
     ipc.server.broadcast(processKey + '.remove', data)
   }
 
+  // ---------------------------------------------------------------------------
+
   module.exports = webtorrentnode
 })()