deno server

This commit is contained in:
bobbydigitales
2024-10-09 20:03:57 -07:00
parent 26ed3bcf84
commit 101f8e15b2
5 changed files with 238 additions and 164 deletions

View File

@@ -174,6 +174,7 @@ class wsConnection {
this.websocket.send(json);
}
helloResponseHandler(data) {
debugger;
let users = [];
try {
let currentUserPeers = data.userPeers[app.router.userID];
@@ -186,8 +187,8 @@ class wsConnection {
users = [...users, ...Object.entries(data.userPeers)];
log(`Net: got ${users.length} users from bootstrap peer. ${users.join(',')}`);
for (let [userID, peerIDs] of users) {
this.peers.set(userID, [...Object.keys(peerIDs)]);
for (let peerID of [...Object.keys(peerIDs)]) {
this.peers.set(userID, [...peerIDs]);
for (let peerID of [...peerIDs]) {
if (peerID === this.peerID) {
continue;
}
@@ -228,6 +229,7 @@ class wsConnection {
// return compressedArrayBuffer;
// }
async getPostIdsForUserHandler(data) {
debugger;
let message = data.message;
let postIds = await getAllIds(message.user_id) ?? [];
if (postIds.length === 0) {
@@ -331,6 +333,7 @@ class wsConnection {
};
this.websocket.onmessage = (event) => {
// log('ws:<-' + event.data.slice(0, 240));
debugger;
let data = JSON.parse(event.data);
let { type } = data;
let handler = this.messageHandlers.get(type);