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 = {}
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
})()