tweak userLeaving and Base

This commit is contained in:
Joao Victor 2022-10-07 10:38:50 -03:00
parent 45199cb6eb
commit 010f1c2964
2 changed files with 26 additions and 12 deletions

View File

@ -45,7 +45,18 @@ export default function userLeaving(meetingId, userId, connectionId) {
ClientConnections.removeClientConnection(`${meetingId}--${userId}`, connectionId); ClientConnections.removeClientConnection(`${meetingId}--${userId}`, connectionId);
const reason = user.loggedOut ? 'logout' : 'disconnection'; let reason;
if (user.loggedOut) {
// User explicitly requested logout.
reason = 'logout';
} else if (user.exitReason) {
// User didn't requested logout but exited graciously.
reason = user.exitReason;
} else {
// User didn't exit graciously (disconnection).
reason = 'disconnection';
}
Logger.info(`User '${userId}' is leaving meeting '${meetingId}' reason=${reason}`); Logger.info(`User '${userId}' is leaving meeting '${meetingId}' reason=${reason}`);
RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload); RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);

View File

@ -240,7 +240,7 @@ class Base extends Component {
} }
static async setExitReason(reason) { static async setExitReason(reason) {
return makeCall('setExitReason', reason); return await makeCall('setExitReason', reason);
} }
renderByState() { renderByState() {
@ -264,8 +264,10 @@ class Base extends Component {
} }
if (meetingIsBreakout && (ejected || userRemoved)) { if (meetingIsBreakout && (ejected || userRemoved)) {
Base.setExitReason('removedFromBreakout'); Base.setExitReason('removedFromBreakout').finally(() => {
window.close(); Meteor.disconnect();
window.close();
});
return null; return null;
} }
@ -275,14 +277,15 @@ class Base extends Component {
} }
if ((meetingHasEnded || User?.loggedOut) && meetingIsBreakout) { if ((meetingHasEnded || User?.loggedOut) && meetingIsBreakout) {
if (meetingHasEnded) { const reason = meetingHasEnded ? 'breakoutEnded' : 'logout';
Base.setExitReason('breakoutEnded'); Base.setExitReason(reason).finally(() => {
} Meteor.disconnect();
window.close(); window.close();
});
return null; return null;
} }
if (((meetingHasEnded && !meetingIsBreakout)) || (codeError && User?.loggedOut)) { if (meetingHasEnded && !meetingIsBreakout) {
Base.setExitReason('meetingEnded'); Base.setExitReason('meetingEnded');
return ( return (
<MeetingEnded <MeetingEnded
@ -294,12 +297,12 @@ class Base extends Component {
} }
if (codeError && !meetingHasEnded) { if (codeError && !meetingHasEnded) {
// 680 is set for the codeError when the user requests a logout // 680 is set for the codeError when the user requests a logout.
if (codeError !== '680') { if (codeError !== '680') {
if (codeError === '503') Base.setExitReason('disconnected'); Base.setExitReason('error');
else Base.setExitReason('error');
return (<ErrorScreen code={codeError} />); return (<ErrorScreen code={codeError} />);
} }
Base.setExitReason('logout');
return (<MeetingEnded code={codeError} />); return (<MeetingEnded code={codeError} />);
} }