Skip to content

Commit bf3080d

Browse files
author
Alberto Iannaccone
committed
enable/disable agent
1 parent c182b7f commit bf3080d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/socket-daemon.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default class SocketDaemon extends Daemon {
5858
this.selectedProtocol = PROTOCOL.HTTP;
5959
this.socket = null;
6060
this.pluginURL = null;
61+
this.disabled = false;
6162

6263
this.openChannel(() => this.socket.emit('command', 'list'));
6364

@@ -92,6 +93,9 @@ export default class SocketDaemon extends Daemon {
9293
* First search in LOOPBACK_ADDRESS, after in LOOPBACK_HOST if in Chrome or Firefox, otherwise vice versa.
9394
*/
9495
findAgent() {
96+
if (this.disabled) {
97+
return;
98+
}
9599
if (this.pluginURL) {
96100
fetch(`${this.pluginURL}/info`)
97101
.then(response => response.json().then(data => {
@@ -546,4 +550,13 @@ export default class SocketDaemon extends Daemon {
546550
});
547551
this.socket.emit('command', 'killupload');
548552
}
553+
554+
disable() {
555+
this.disabled = true;
556+
}
557+
558+
enable() {
559+
this.disable = false;
560+
this.findAgent();
561+
}
549562
}

0 commit comments

Comments
 (0)