Hello working

This commit is contained in:
“bobbydigitales”
2024-10-09 12:20:16 -07:00
parent 26ed3bcf84
commit dd66a5d31b
4 changed files with 22 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
// deno-lint-ignore-file prefer-const no-explicit-any
function serveFile(filename: string) {
console.log(filename)
const responseText = Deno.readFileSync("../" + filename);
@@ -47,10 +48,19 @@ function helloHandler(m:HelloMessage) {
userPeers.get(knownUserID)?.add(m.peer_id);
}
const peersToReturn = JSON.stringify(userPeers);
console.log(peersToReturn);
let returnValue:any = {};
for (let key of userPeers.keys()) {
let peers = userPeers.get(key);
if (!peers) {
continue;
}
returnValue[key] = [...peers.keys()];
}
return JSON.stringify({type:'hello', userPeers: peersToReturn});
console.log(returnValue);
return JSON.stringify({type:'hello', userPeers: returnValue});
}
const messageDispatch:Map<string, (event:Record<string, never>)=>string> = new Map();