|
5 | 5 |
|
6 | 6 | import asyncio |
7 | 7 | import json |
8 | | -import time |
9 | 8 | import uuid |
10 | 9 | from logging import Logger |
11 | 10 | from typing import Any, Literal |
|
15 | 14 | from jupyter_server.base.handlers import APIHandler, JupyterHandler |
16 | 15 | from jupyter_server.utils import ensure_async |
17 | 16 | from jupyter_ydoc import ydocs as YDOCS |
18 | | -from pycrdt import Doc, UndoManager, write_var_uint |
| 17 | +from pycrdt import Doc, UndoManager |
19 | 18 | from pycrdt_websocket.websocket_server import YRoom |
20 | 19 | from pycrdt_websocket.ystore import BaseYStore |
21 | 20 | from tornado import web |
|
28 | 27 | JUPYTER_COLLABORATION_EVENTS_URI, |
29 | 28 | JUPYTER_COLLABORATION_FORK_EVENTS_URI, |
30 | 29 | LogLevel, |
31 | | - MessageType, |
32 | 30 | decode_file_path, |
33 | 31 | encode_file_path, |
34 | 32 | room_id_from_encoded_path, |
@@ -290,28 +288,6 @@ async def on_message(self, message): |
290 | 288 | """ |
291 | 289 | On message receive. |
292 | 290 | """ |
293 | | - message_type = message[0] |
294 | | - |
295 | | - if message_type == MessageType.CHAT: |
296 | | - msg = message[2:].decode("utf-8") |
297 | | - |
298 | | - user = self.current_user |
299 | | - data = json.dumps( |
300 | | - { |
301 | | - "sender": user.username, |
302 | | - "timestamp": time.time(), |
303 | | - "content": json.loads(msg), |
304 | | - } |
305 | | - ).encode("utf8") |
306 | | - |
307 | | - for client in self.room.clients: |
308 | | - if client != self: |
309 | | - task = asyncio.create_task( |
310 | | - client.send(bytes([MessageType.CHAT]) + write_var_uint(len(data)) + data) |
311 | | - ) |
312 | | - self._websocket_server.background_tasks.add(task) |
313 | | - task.add_done_callback(self._websocket_server.background_tasks.discard) |
314 | | - |
315 | 291 | self._message_queue.put_nowait(message) |
316 | 292 | self._websocket_server.ypatch_nb += 1 |
317 | 293 |
|
|
0 commit comments