Click a face to follow them: their tab, their frame, their play, their pointer
A collaborator's face in the top bar follows them. You go where they go — the symbol they open, the frame they are on, play when they play — and each of you sees the other's pointer on the stage, named and in their colour. Clicking the face again, ringed while you are together, leaves. tl's parties, nearly line for line. Nobody hosts: following someone on their own takes their connection id as the party, so two people following each other at once land in one, and anyone in it drives the rest. That is why the eye beside the faces says whether you may be followed. The browsers work it out from gossip; the server only relays `nav` and `cursor`, and does not remember them. Only deliberate moves go out. Every member plays the document off its own clock, so a play is sent once with its frame rather than streamed. A dive into a symbol made a moment ago waits for its write to land, and a dropped socket rejoins the same party on the way back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
14b0d6fa85
commit
fbdecfb5d2
10 changed files with 502 additions and 53 deletions
|
|
@ -4,7 +4,8 @@ Two things ride it. DELTAS, which the server sends after a write commits — the
|
|||
socket is read-only for the document, and a dropped socket cannot lose a write.
|
||||
PRESENCE, which peers gossip between themselves: all the server does is hand out
|
||||
a connection id and stamp the sender's identity onto every message, so nobody can
|
||||
post as somebody else.
|
||||
post as somebody else. A party — people following each other — is worked out in
|
||||
the browsers from that gossip (`arthur.domain.party`); nothing here knows of it.
|
||||
"""
|
||||
import json
|
||||
import uuid
|
||||
|
|
@ -32,7 +33,10 @@ def broadcast(project_id, delta, kind="delta"):
|
|||
|
||||
|
||||
class ProjectConsumer(AsyncWebsocketConsumer):
|
||||
RELAYED = ("state",)
|
||||
# `state` is who you are and which party you carry, and is remembered for
|
||||
# the next joiner. `nav` and `cursor` are where a party is looking, and are
|
||||
# stale the moment the next one is sent, so they are only passed on.
|
||||
RELAYED = ("state", "nav", "cursor")
|
||||
|
||||
@property
|
||||
def room(self):
|
||||
|
|
@ -68,7 +72,7 @@ class ProjectConsumer(AsyncWebsocketConsumer):
|
|||
return
|
||||
if not isinstance(msg, dict) or msg.get("kind") not in self.RELAYED:
|
||||
return
|
||||
if self.cid in self.room:
|
||||
if msg["kind"] == "state" and self.cid in self.room:
|
||||
self.room[self.cid].update(
|
||||
{k: v for k, v in msg.items() if k not in ("kind", "cid", "user")}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue