fix(presence): relay presence-leave messages and clean up listener on disconnect
- Server now relays presence-leave alongside presence messages for immediate peer removal - Overlay properly unsubscribes leave listener on disconnectedCallback Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
2f8ce08e3c
commit
1c338529bf
|
|
@ -3451,10 +3451,10 @@ const server = Bun.serve<WSData>({
|
||||||
}
|
}
|
||||||
} else if (msg.type === "ping") {
|
} else if (msg.type === "ping") {
|
||||||
ws.send(JSON.stringify({ type: "pong", timestamp: msg.timestamp }));
|
ws.send(JSON.stringify({ type: "pong", timestamp: msg.timestamp }));
|
||||||
} else if (msg.type === "presence") {
|
} else if (msg.type === "presence" || msg.type === "presence-leave") {
|
||||||
const clients = communityClients.get(communitySlug);
|
const clients = communityClients.get(communitySlug);
|
||||||
if (clients) {
|
if (clients) {
|
||||||
const presenceMsg = JSON.stringify({ type: "presence", peerId, ...msg });
|
const presenceMsg = JSON.stringify({ ...msg, peerId });
|
||||||
for (const [clientPeerId, client] of clients) {
|
for (const [clientPeerId, client] of clients) {
|
||||||
if (clientPeerId !== peerId && client.readyState === WebSocket.OPEN) {
|
if (clientPeerId !== peerId && client.readyState === WebSocket.OPEN) {
|
||||||
client.send(presenceMsg);
|
client.send(presenceMsg);
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ export class RStackCollabOverlay extends HTMLElement {
|
||||||
window.removeEventListener('rspace-doc-subscribe', this.#onDocSubscribe);
|
window.removeEventListener('rspace-doc-subscribe', this.#onDocSubscribe);
|
||||||
this.#unsubAwareness?.();
|
this.#unsubAwareness?.();
|
||||||
this.#unsubPresence?.();
|
this.#unsubPresence?.();
|
||||||
|
this.#unsubLeave?.();
|
||||||
this.#stopMouseTracking();
|
this.#stopMouseTracking();
|
||||||
this.#stopFocusTracking();
|
this.#stopFocusTracking();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue