Skip to content

Commit

Permalink
add some console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
davwas committed Nov 16, 2023
1 parent c2769d8 commit 7396910
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
27 changes: 16 additions & 11 deletions apps/server/src/modules/tldraw/domain/ws-shared-doc.do.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ export class WsSharedDocDo extends Doc {
await this.tldrawService.updateHandler(update, origin, doc);
});

void this.tldrawService.sub.subscribe(this.name, this.awarenessChannel).then(() => {
this.tldrawService.sub.on('messageBuffer', (channel, update: Uint8Array) => {
const channelId = channel.toString();
this.tldrawService.sub
.subscribe(this.name, this.awarenessChannel)
.then(() => {
console.log('SUBSCRIBED TO CHANNELS');
this.tldrawService.sub.on('messageBuffer', (channel, update: Uint8Array) => {
const channelId = channel.toString();
console.log('LISTENED TO MESSAGEBUFFER ON: ', channelId);

if (channelId === this.name) {
applyUpdate(this, update, this.tldrawService.sub);
} else if (channelId === this.awarenessChannel) {
applyAwarenessUpdate(this.awareness, update, this.tldrawService.sub);
}
});
return null;
});
if (channelId === this.name) {
applyUpdate(this, update, this.tldrawService.sub);
} else if (channelId === this.awarenessChannel) {
applyAwarenessUpdate(this.awareness, update, this.tldrawService.sub);
}
});
return null;
})
.catch((err) => console.log(err));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions apps/server/src/modules/tldraw/service/tldraw.ws.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class TldrawWsService {
doc.destroy();
return null;
})
.catch(() => {});
.catch((err) => console.log(err));
this.docs.delete(doc.name);
}
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export class TldrawWsService {
return map.setIfUndefined(this.docs, docName, () => {
const doc = new WsSharedDocDo(docName, this, gc);
if (this.persistence !== null) {
this.persistence.bindState(docName, doc).catch(() => {});
this.persistence.bindState(docName, doc).catch((err) => console.log(err));
}
this.docs.set(docName, doc);
return doc;
Expand Down

0 comments on commit 7396910

Please sign in to comment.