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
|
|
@ -1227,3 +1227,37 @@ class SocketTests(TestCase):
|
|||
await peer.disconnect()
|
||||
|
||||
async_to_sync(scenario)()
|
||||
|
||||
def test_where_a_party_looks_is_passed_on_and_not_remembered(self):
|
||||
from asgiref.sync import async_to_sync
|
||||
from channels.testing import WebsocketCommunicator
|
||||
from server.asgi import application
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
project = Project.objects.create(
|
||||
name="shared", owner=get_user_model().objects.create_user("host"))
|
||||
|
||||
async def join():
|
||||
peer = WebsocketCommunicator(application, f"/ws/projects/{project.id}",
|
||||
headers=[(b"origin", b"http://localhost")])
|
||||
self.assertTrue((await peer.connect())[0])
|
||||
welcome = await peer.receive_json_from()
|
||||
roster = (await peer.receive_json_from())["peers"]
|
||||
await peer.receive_json_from() # our own join
|
||||
return peer, welcome["cid"], roster
|
||||
|
||||
async def scenario():
|
||||
a, a_cid, _ = await join()
|
||||
await a.send_json_to({"kind": "state", "party": a_cid, "joinable": True})
|
||||
await a.receive_json_from()
|
||||
await a.send_json_to({"kind": "nav", "open": "main", "frame": 7, "playing": True})
|
||||
self.assertEqual(7, (await a.receive_json_from())["frame"])
|
||||
await a.send_json_to({"kind": "cursor", "open": "main", "at": [3, 4]})
|
||||
self.assertEqual([3, 4], (await a.receive_json_from())["at"])
|
||||
|
||||
b, _, roster = await join()
|
||||
self.assertEqual([{"cid": a_cid, "user": None, "party": a_cid, "joinable": True}],
|
||||
roster)
|
||||
await a.disconnect(); await b.disconnect()
|
||||
|
||||
async_to_sync(scenario)()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue