REVERT: I'm not proud
This is slow af Definitely needs more work
This commit is contained in:
@@ -1,26 +1,47 @@
|
||||
"use strict";
|
||||
|
||||
class trserver extends EventTarget {
|
||||
#name;
|
||||
get name() {
|
||||
return this.#name;
|
||||
}
|
||||
#rpcurl;
|
||||
#authHeader;
|
||||
#sessionHeader;
|
||||
#requests = [];
|
||||
#torrents = {};
|
||||
#isOnline = false;
|
||||
#setOnline(online) {
|
||||
if (this.isOnline == online) {
|
||||
return;
|
||||
}
|
||||
this.#isOnline = online;
|
||||
let detail = {
|
||||
};
|
||||
let etype;
|
||||
if (online) {
|
||||
etype = 'torrentserver-online';
|
||||
}
|
||||
else {
|
||||
etype = 'torrentserver-offline';
|
||||
}
|
||||
this.dispatchEvent(new CustomEvent(etype, detail));
|
||||
}
|
||||
|
||||
#logger = function(msg) {};
|
||||
#torrentCallback = function(hash, torrentInfo) {
|
||||
let e = new CustomEvent('torrent-update', {
|
||||
'detail': {
|
||||
'torrentHash': hash,
|
||||
'torrentInfo': torrentInfo
|
||||
detail: {
|
||||
torrentHash: hash,
|
||||
torrentInfo: torrentInfo
|
||||
}
|
||||
});
|
||||
this.dispatchEvent(e);
|
||||
};
|
||||
|
||||
constructor (initdata, logger = null, tcb = null) {
|
||||
constructor (name, initdata, logger = null, tcb = null) {
|
||||
super();
|
||||
this.#name = name;
|
||||
this.#rpcurl = initdata.rpcurl;
|
||||
if (logger != null) {
|
||||
this.#logger = logger;
|
||||
|
||||
Reference in New Issue
Block a user