|
@@ -1,6 +1,7 @@
|
|
|
import { Server } from 'socket.io';
|
|
import { Server } from 'socket.io';
|
|
|
import { YSocketIO } from 'y-socket.io/dist/server';
|
|
import { YSocketIO } from 'y-socket.io/dist/server';
|
|
|
|
|
|
|
|
|
|
+import { SocketEventName } from '~/interfaces/websocket';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import { RoomPrefix, getRoomNameWithId } from '../util/socket-io-helpers';
|
|
import { RoomPrefix, getRoomNameWithId } from '../util/socket-io-helpers';
|
|
@@ -165,13 +166,13 @@ class SocketIoService {
|
|
|
|
|
|
|
|
setupYjsConnection() {
|
|
setupYjsConnection() {
|
|
|
this.io.on('connection', (socket) => {
|
|
this.io.on('connection', (socket) => {
|
|
|
- socket.on('ydoc:sync', async({ pageId, initialValue }) => {
|
|
|
|
|
|
|
+ socket.on(SocketEventName.YDocSync, async({ pageId, initialValue }) => {
|
|
|
try {
|
|
try {
|
|
|
await this.yjsConnectionManager.handleYDocSync(pageId, initialValue);
|
|
await this.yjsConnectionManager.handleYDocSync(pageId, initialValue);
|
|
|
}
|
|
}
|
|
|
catch (error) {
|
|
catch (error) {
|
|
|
logger.warn(error.message);
|
|
logger.warn(error.message);
|
|
|
- socket.emit('ydoc:sync:error', 'An error occurred during YDoc synchronization.');
|
|
|
|
|
|
|
+ socket.emit(SocketEventName.YDocSyncError, 'An error occurred during YDoc synchronization.');
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|