Skip to content

Commit 73da762

Browse files
committed
Support document fork
1 parent 0e19a6a commit 73da762

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pycrdt_websocket/yroom.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
class YRoom:
3535
clients: set[Websocket]
36+
fork_ydocs: set[Doc]
3637
ydoc: Doc
3738
ystore: BaseYStore | None
3839
ready_event: Event
@@ -83,6 +84,7 @@ def __init__(
8384
self.ystore = ystore
8485
self.log = log or getLogger(__name__)
8586
self.clients = set()
87+
self.fork_ydocs = set()
8688
self._on_message = None
8789
self.exception_handler = exception_handler
8890
self._stopped = Event()
@@ -149,12 +151,15 @@ async def _broadcast_updates(self):
149151
return
150152
# broadcast internal ydoc's update to all clients, that includes changes from the
151153
# clients and changes from the backend (out-of-band changes)
154+
for ydoc in self.fork_ydocs:
155+
ydoc.apply_update(update)
156+
152157
if self.clients:
153158
message = create_update_message(update)
154159
for client in self.clients:
155160
try:
156161
self.log.debug(
157-
"Sending Y update to client with endpoint: %s", client.path
162+
"Sending Y update to remote client with endpoint: %s", client.path
158163
)
159164
self._task_group.start_soon(client.send, message)
160165
except Exception as exception:

0 commit comments

Comments
 (0)