Hello working
This commit is contained in:
16
deno/main.ts
16
deno/main.ts
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user