fix: clear editors on disconnect
This commit is contained in:
parent
8bcc16f790
commit
3b7756924f
2 changed files with 25 additions and 1 deletions
|
@ -32,6 +32,31 @@ export default (io: Server, socket: Socket) => {
|
|||
const socketRooms = Array.from(socket.rooms).filter((room) => room !== socket.id && room !== "home");
|
||||
if (socketRooms[0]) {
|
||||
socket.leave(socketRooms[0]);
|
||||
MissionMap.updateAwareness(socketRooms[0], {
|
||||
action: "remove",
|
||||
store: "editors",
|
||||
update: undefined,
|
||||
socketId: socket.id,
|
||||
});
|
||||
io.to(socketRooms[0]).emit("package-sync-awareness", {
|
||||
type: "editors",
|
||||
update: undefined,
|
||||
action: "remove",
|
||||
socketId: socket.id,
|
||||
});
|
||||
|
||||
MissionMap.updateAwareness(socketRooms[0], {
|
||||
action: "remove",
|
||||
store: "state",
|
||||
update: undefined,
|
||||
socketId: socket.id,
|
||||
});
|
||||
io.to(socketRooms[0]).emit("package-sync-awareness", {
|
||||
type: "state",
|
||||
update: undefined,
|
||||
action: "remove",
|
||||
socketId: socket.id,
|
||||
});
|
||||
const clients = io.sockets.adapter.rooms.get(socketRooms[0]);
|
||||
if (!clients || clients.size == 0) {
|
||||
MissionMap.delete(socketRooms[0]);
|
||||
|
|
|
@ -47,7 +47,6 @@ export default (io: Server, socket: Socket) => {
|
|||
});
|
||||
}
|
||||
|
||||
console.log(MissionDocHelper.getAwarenessEditors(missionId));
|
||||
socket.emit("package-init-awareness", {
|
||||
update: MissionDocHelper.getAwarenessEditors(missionId),
|
||||
type: "editors",
|
||||
|
|
Loading…
Add table
Reference in a new issue