REVERT: I'm not proud

This is slow af
Definitely needs more work
This commit is contained in:
2025-10-09 15:42:31 +02:00
parent b2f155c0b4
commit 53ae5495aa
6 changed files with 245 additions and 99 deletions

View File

@@ -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;