diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2015-11-02 22:42:27 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2015-11-03 08:10:30 +0100 |
commit | 4634cfb353d47a381e19c72f6887fc68f6fbc4bf (patch) | |
tree | 3bd8a4a0dd77d7f99350f0f359f3c6a712880b58 /src | |
parent | 0ae2e7f73c24779f8c99453fb02491382cc0520e (diff) | |
download | PeerTube-4634cfb353d47a381e19c72f6887fc68f6fbc4bf.tar.gz PeerTube-4634cfb353d47a381e19c72f6887fc68f6fbc4bf.tar.zst PeerTube-4634cfb353d47a381e19c72f6887fc68f6fbc4bf.zip |
Off the events of the ipc task done in webtorrent node
Diffstat (limited to 'src')
-rw-r--r-- | src/webTorrentNode.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/webTorrentNode.js b/src/webTorrentNode.js index 507cf31fc..bc77872ce 100644 --- a/src/webTorrentNode.js +++ b/src/webTorrentNode.js | |||
@@ -88,7 +88,8 @@ | |||
88 | if (!webtorrentnode.silent) logger.debug('Node wants to seed ' + data._id) | 88 | if (!webtorrentnode.silent) logger.debug('Node wants to seed ' + data._id) |
89 | 89 | ||
90 | // Finish signal | 90 | // Finish signal |
91 | ipc.server.on(nodeKey + '.seedDone.' + data._id, function (received) { | 91 | var event_key = nodeKey + '.seedDone.' + data._id |
92 | ipc.server.on(event_key, function listener (received) { | ||
92 | if (!webtorrentnode.silent) logger.debug('Process seeded torrent ' + received.magnetUri) | 93 | if (!webtorrentnode.silent) logger.debug('Process seeded torrent ' + received.magnetUri) |
93 | 94 | ||
94 | // This is a fake object, we just use the magnetUri in this project | 95 | // This is a fake object, we just use the magnetUri in this project |
@@ -96,6 +97,7 @@ | |||
96 | magnetURI: received.magnetUri | 97 | magnetURI: received.magnetUri |
97 | } | 98 | } |
98 | 99 | ||
100 | ipc.server.off(event_key) | ||
99 | callback(torrent) | 101 | callback(torrent) |
100 | }) | 102 | }) |
101 | 103 | ||
@@ -113,7 +115,8 @@ | |||
113 | if (!webtorrentnode.silent) logger.debug('Node wants to add ' + data._id) | 115 | if (!webtorrentnode.silent) logger.debug('Node wants to add ' + data._id) |
114 | 116 | ||
115 | // Finish signal | 117 | // Finish signal |
116 | ipc.server.on(nodeKey + '.addDone.' + data._id, function (received) { | 118 | var event_key = nodeKey + '.addDone.' + data._id |
119 | ipc.server.on(event_key, function (received) { | ||
117 | if (!webtorrentnode.silent) logger.debug('Process added torrent') | 120 | if (!webtorrentnode.silent) logger.debug('Process added torrent') |
118 | 121 | ||
119 | // This is a fake object, we just use the magnetUri in this project | 122 | // This is a fake object, we just use the magnetUri in this project |
@@ -121,6 +124,7 @@ | |||
121 | files: received.files | 124 | files: received.files |
122 | } | 125 | } |
123 | 126 | ||
127 | ipc.server.off(event_key) | ||
124 | callback(torrent) | 128 | callback(torrent) |
125 | }) | 129 | }) |
126 | 130 | ||
@@ -138,12 +142,14 @@ | |||
138 | if (!webtorrentnode.silent) logger.debug('Node wants to stop seeding ' + data._id) | 142 | if (!webtorrentnode.silent) logger.debug('Node wants to stop seeding ' + data._id) |
139 | 143 | ||
140 | // Finish signal | 144 | // Finish signal |
141 | ipc.server.on(nodeKey + '.removeDone.' + data._id, function (received) { | 145 | var event_key = nodeKey + '.removeDone.' + data._id |
146 | ipc.server.on(event_key, function (received) { | ||
142 | if (!webtorrentnode.silent) logger.debug('Process removed torrent ' + data._id) | 147 | if (!webtorrentnode.silent) logger.debug('Process removed torrent ' + data._id) |
143 | 148 | ||
144 | var err = null | 149 | var err = null |
145 | if (received.err) err = received.err | 150 | if (received.err) err = received.err |
146 | 151 | ||
152 | ipc.server.off(event_key) | ||
147 | callback(err) | 153 | callback(err) |
148 | }) | 154 | }) |
149 | 155 | ||