* Unified profiles, rather than instantiating profiles every time we want to access one

* Socket and live instance changes
* Possible problem with Deno's handling of sockets, compatibility issue with Node?
This commit is contained in:
2025-03-27 20:00:17 -04:00
parent dd7d929918
commit 492129df17
15 changed files with 147 additions and 82 deletions

View File

@@ -11,10 +11,14 @@ function randomId(length: number) {
return result;
}
// Lots of this is redundant. The WebSocket request already contains an access token for the profile, but I'd
// like to make sure that connectionIds are freed automatically.
/**
* Reserve `connectionId`s for each connected client, hand off to socket handler when complete or timed out
*/
export class SocketHandoff {
static all() {
return Array.from(handoffs.values());
}
static generateId() {
let id = randomId(48);
while (handoffs.values().find(handoff => handoff.id == id)) id = randomId(48);
@@ -32,19 +36,15 @@ export class SocketHandoff {
this.id = SocketHandoff.generateId();
this.#timeout = setTimeout(() => {
handoffs.delete(this);
this.complete();
});
handoffs.add(this);
}
delete() {
complete() {
clearTimeout(this.#timeout);
handoffs.delete(this);
}
complete() {
this.delete();
}
}