Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions jupyter_server_documents/rooms/yroom.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,17 +526,11 @@ def handle_message(self, client_id: str, message: bytes) -> None:
self.log.debug(f"Handled AwarenessUpdate from '{client_id}' for room '{self.room_id}'.")
# Handle Sync messages
elif sync_message_subtype == YSyncMessageSubtype.SYNC_STEP1:
self.log.info(f"Received SS1 from '{client_id}' for room '{self.room_id}'.")
self.handle_sync_step1(client_id, message)
self.log.info(f"Handled SS1 from '{client_id}' for room '{self.room_id}'.")
elif sync_message_subtype == YSyncMessageSubtype.SYNC_STEP2:
self.log.info(f"Received SS2 from '{client_id}' for room '{self.room_id}'.")
self.handle_sync_step2(client_id, message)
self.log.info(f"Handled SS2 from '{client_id}' for room '{self.room_id}'.")
elif sync_message_subtype == YSyncMessageSubtype.SYNC_UPDATE:
self.log.info(f"Received SyncUpdate from '{client_id} for room '{self.room_id}''.")
self.handle_sync_update(client_id, message)
self.log.info(f"Handled SyncUpdate from '{client_id} for room '{self.room_id}''.")


def handle_sync_step1(self, client_id: str, message: bytes) -> None:
Expand Down Expand Up @@ -570,23 +564,21 @@ def handle_sync_step1(self, client_id: str, message: bytes) -> None:
# TODO: remove the assert once websocket is made required
assert isinstance(new_client.websocket, WebSocketHandler)
new_client.websocket.write_message(sync_step2_message, binary=True)
self.log.info(f"Sent SS2 reply to client '{client_id}'.")
except Exception as e:
self.log.error(
"An exception occurred when writing the SyncStep2 reply "
f"to new client '{new_client.id}':"
)
self.log.exception(e)
return

self.clients.mark_synced(client_id)

# Send SyncStep1 message
try:
assert isinstance(new_client.websocket, WebSocketHandler)
sync_step1_message = pycrdt.create_sync_message(self._ydoc)
new_client.websocket.write_message(sync_step1_message, binary=True)
self.log.info(f"Sent SS1 message to client '{client_id}'.")
except Exception as e:
self.log.error(
"An exception occurred when writing a SyncStep1 message "
Expand Down Expand Up @@ -777,11 +769,6 @@ def _broadcast_message(self, message: bytes, message_type: Literal['AwarenessUpd
if not client_count:
return

if message_type == "SyncUpdate":
self.log.info(
f"Broadcasting {message_type} to all {client_count} synced clients."
)

for client in clients:
try:
# TODO: remove this assertion once websocket is made required
Expand All @@ -795,11 +782,6 @@ def _broadcast_message(self, message: bytes, message_type: Literal['AwarenessUpd
)
self.log.exception(e)
continue

if message_type == "SyncUpdate":
self.log.info(
f"Broadcast of {message_type} complete for room {self.room_id}."
)

def _on_awareness_update(self, type: str, changes: tuple[dict[str, Any], Any]) -> None:
"""
Expand Down
Loading