checkpoint

This commit is contained in:
bobbydigitales
2025-03-25 20:04:52 -07:00
parent 71b5284b0f
commit 0b5fee4aca
12 changed files with 240 additions and 138 deletions

View File

@@ -109,7 +109,7 @@ function helloHandler(m: HelloMessage, socket: WebSocket) {
userPeers.set(m.user_id, new Set());
}
userPeers.get(m.user_id)?.add(m.peer_id);
peerSockets.set(m.peer_id, socket);
peerSockets.set(m.peer_id, socket); // TODO:MAYBEBUG - what happens with multiple windows each with their own websocket?
socketPeers.set(socket, m.peer_id);
if (Symbol.iterator in Object(m.known_users)) {
@@ -123,9 +123,6 @@ function helloHandler(m: HelloMessage, socket: WebSocket) {
}
}
const returnValue: any = {};
for (const key of userPeers.keys()) {
const peers = userPeers.get(key);
@@ -173,7 +170,10 @@ function peerMessageHandler(m: PeerMessage, _socket: WebSocket) {
const messageToSend = JSON.stringify(m);
// console.log("ws->", toPeer, messageToSend);
console.log("peerMessageHandler: before toPeer.send");
toPeer.send(messageToSend)
console.log("peerMessageHandler: after toPeer.send");
return null;
}
@@ -304,11 +304,11 @@ async function main() {
Deno.serve({
port: 6789,
cert: Deno.readTextFileSync("/etc/letsencrypt/live/ddlion.net/fullchain.pem"),
key: Deno.readTextFileSync("/etc/letsencrypt/live/ddlion.net/privkey.pem"),
cert: Deno.readTextFileSync("/etc/letsencrypt/live/ddln.app/fullchain.pem"),
key: Deno.readTextFileSync("/etc/letsencrypt/live/ddln.app/privkey.pem"),
}, handler);
await devServerWatchFiles();
}
await main();
await main();