Просмотр исходного кода

Modified to emit to itself as well

Shun Miyazawa 1 год назад
Родитель
Сommit
6130ab6cb6
1 измененных файлов с 4 добавлено и 3 удалено
  1. 4 3
      apps/app/src/server/service/socket-io.js

+ 4 - 3
apps/app/src/server/service/socket-io.js

@@ -160,13 +160,14 @@ class SocketIoService {
     const yjsConnectionManager = getYjsConnectionManager();
     const yjsConnectionManager = getYjsConnectionManager();
     this.io.on('connection', (socket) => {
     this.io.on('connection', (socket) => {
       socket.on(GlobalSocketEventName.YDocSync, async({ pageId, initialValue }) => {
       socket.on(GlobalSocketEventName.YDocSync, async({ pageId, initialValue }) => {
-        // Tell client that a draft has been created
-        socket
+
+        // Emit to the client in the room of the target pageId.
+        this.io
           .in(getRoomNameWithId(RoomPrefix.PAGE, pageId))
           .in(getRoomNameWithId(RoomPrefix.PAGE, pageId))
           .emit(SocketEventName.YjsUpdated, true);
           .emit(SocketEventName.YjsUpdated, true);
 
 
         try {
         try {
-          await yjsConnectionManager.handleYDocSync(pageId, initialValue, socket);
+          await yjsConnectionManager.handleYDocSync(pageId, initialValue);
         }
         }
         catch (error) {
         catch (error) {
           logger.warn(error.message);
           logger.warn(error.message);