PadMessageHandler: Also send `USER_NEWINFO` messages on reconnect
Now the user list is correct after a reconnect. This also allows ep_webrtc to automatically recover after a temporary network glitch.pull/5074/head
parent
7ca336c28e
commit
53cca5a743
|
@ -1121,36 +1121,27 @@ const handleClientReady = async (socket, message, authorID) => {
|
|||
|
||||
// Save the current revision in sessioninfos, should be the same as in clientVars
|
||||
sessionInfo.rev = pad.getHeadRevisionNumber();
|
||||
}
|
||||
|
||||
// prepare the notification for the other users on the pad, that this user joined
|
||||
const messageToTheOtherUsers = {
|
||||
// Notify other users about this new user.
|
||||
socket.broadcast.to(padIds.padId).json.send({
|
||||
type: 'COLLABROOM',
|
||||
data: {
|
||||
type: 'USER_NEWINFO',
|
||||
userInfo: {
|
||||
colorId: authorColorId,
|
||||
name: authorName,
|
||||
userId: authorID,
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
// Add the authorname of this new User, if avaiable
|
||||
if (authorName != null) {
|
||||
messageToTheOtherUsers.data.userInfo.name = authorName;
|
||||
}
|
||||
|
||||
// notify all existing users about new user
|
||||
socket.broadcast.to(padIds.padId).json.send(messageToTheOtherUsers);
|
||||
|
||||
// Get sessions for this pad and update them (in parallel)
|
||||
// Notify this new user about other users.
|
||||
await Promise.all(_getRoomSockets(pad.id).map(async (roomSocket) => {
|
||||
// Jump over, if this session is the connection session
|
||||
if (roomSocket.id === socket.id) {
|
||||
return;
|
||||
}
|
||||
if (roomSocket.id === socket.id) return;
|
||||
|
||||
// Since sessioninfos might change while being enumerated, check if the
|
||||
// sessionID is still assigned to a valid session
|
||||
// sessioninfos might change while enumerating, so check if the sessionID is still assigned to a
|
||||
// valid session.
|
||||
const sessionInfo = sessioninfos[roomSocket.id];
|
||||
if (sessionInfo == null) return;
|
||||
|
||||
|
@ -1171,7 +1162,6 @@ const handleClientReady = async (socket, message, authorID) => {
|
|||
return;
|
||||
}
|
||||
|
||||
// Send the new User a Notification about this other user
|
||||
const msg = {
|
||||
type: 'COLLABROOM',
|
||||
data: {
|
||||
|
@ -1186,7 +1176,6 @@ const handleClientReady = async (socket, message, authorID) => {
|
|||
|
||||
socket.json.send(msg);
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue