WIP onClose
This commit is contained in:
parent
6e4e0a510a
commit
ac0a014571
@ -4,11 +4,8 @@ import Users from '/imports/api/users';
|
||||
import userJoin from './userJoin';
|
||||
import pendingAuthenticationsStore from '../store/pendingAuthentications';
|
||||
import createDummyUser from '../modifiers/createDummyUser';
|
||||
import setConnectionIdAndAuthToken from '../modifiers/setConnectionIdAndAuthToken';
|
||||
|
||||
import ClientConnections from '/imports/startup/server/ClientConnections';
|
||||
import upsertValidationState from '/imports/api/auth-token-validation/server/modifiers/upsertValidationState';
|
||||
import removeValidationState from '/imports/api/auth-token-validation/server/modifiers/removeValidationState';
|
||||
import { ValidationStates } from '/imports/api/auth-token-validation';
|
||||
|
||||
const clearOtherSessions = (sessionUserId, current = false) => {
|
||||
|
@ -2,8 +2,8 @@ import { Meteor } from 'meteor/meteor';
|
||||
import { check } from 'meteor/check';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import AuthTokenValidation from '/imports/api/auth-token-validation';
|
||||
import Users from '/imports/api/users';
|
||||
import ClientConnections from '/imports/startup/server/ClientConnections';
|
||||
|
||||
export default function userLeaving(meetingId, userId, connectionId) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
@ -23,8 +23,14 @@ export default function userLeaving(meetingId, userId, connectionId) {
|
||||
return Logger.info(`Skipping userLeaving. Could not find ${userId} in ${meetingId}`);
|
||||
}
|
||||
|
||||
const auth = AuthTokenValidation.findOne({
|
||||
meetingId,
|
||||
userId,
|
||||
connectionId,
|
||||
});
|
||||
|
||||
// If the current user connection is not the same that triggered the leave we skip
|
||||
if (User.connectionId !== connectionId) {
|
||||
if (User.connectionId !== connectionId && !auth) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -33,8 +39,6 @@ export default function userLeaving(meetingId, userId, connectionId) {
|
||||
sessionId: meetingId,
|
||||
};
|
||||
|
||||
ClientConnections.removeClientConnection(`${meetingId}--${userId}`, connectionId);
|
||||
|
||||
Logger.info(`User '${userId}' is leaving meeting '${meetingId}'`);
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, userId, payload);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ import { Meteor } from 'meteor/meteor';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import ClientConnections from '/imports/startup/server/ClientConnections';
|
||||
import userLeaving from './userLeaving';
|
||||
import upsertValidationState from '/imports/api/auth-token-validation/server/modifiers/upsertValidationState';
|
||||
import { ValidationStates } from '/imports/api/auth-token-validation';
|
||||
import pendingAuthenticationsStore from '../store/pendingAuthentications';
|
||||
|
@ -2,11 +2,8 @@ import Users from '/imports/api/users';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import AuthTokenValidation, { ValidationStates } from '/imports/api/auth-token-validation';
|
||||
|
||||
import userLeaving from './methods/userLeaving';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
|
||||
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
||||
|
||||
function currentUser() {
|
||||
@ -18,17 +15,6 @@ function currentUser() {
|
||||
check(meetingId, String);
|
||||
check(requesterUserId, String);
|
||||
|
||||
const connectionId = this.connection.id;
|
||||
const onCloseConnection = Meteor.bindEnvironment(() => {
|
||||
try {
|
||||
userLeaving(meetingId, requesterUserId, connectionId);
|
||||
} catch (e) {
|
||||
Logger.error(`Exception while executing userLeaving: ${e}`);
|
||||
}
|
||||
});
|
||||
|
||||
this._session.socket.on('close', _.debounce(onCloseConnection, 100));
|
||||
|
||||
const selector = {
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Logger from './logger';
|
||||
import userLeaving from '/imports/api/users/server/methods/userLeaving';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
class ClientConnections {
|
||||
@ -7,7 +8,7 @@ class ClientConnections {
|
||||
|
||||
setInterval(() => {
|
||||
this.print();
|
||||
}, 20000);
|
||||
}, 30000);
|
||||
}
|
||||
|
||||
add(sessionId, connection) {
|
||||
@ -28,6 +29,10 @@ class ClientConnections {
|
||||
return false;
|
||||
}
|
||||
|
||||
connection.onClose(Meteor.bindEnvironment(() => {
|
||||
userLeaving(meetingId, userId, connection.id);
|
||||
}));
|
||||
|
||||
if (!sessionConnections.has(userId)) {
|
||||
Logger.info(`Creating connections poll for ${userId}`);
|
||||
|
||||
|
@ -258,15 +258,6 @@ class Auth {
|
||||
return;
|
||||
}
|
||||
|
||||
// if (User.validated === true && User.connectionStatus === 'online') {
|
||||
// logger.info({ logCode: 'auth_service_init_streamers', extraInfo: { userId: User.userId } }, 'Calling init streamers functions');
|
||||
// initCursorStreamListener();
|
||||
// initAnnotationsStreamListener();
|
||||
// computation.stop();
|
||||
// clearTimeout(validationTimeout);
|
||||
// // setTimeout to prevent race-conditions with subscription
|
||||
// setTimeout(() => resolve(true), 100);
|
||||
// }
|
||||
const authenticationTokenValidation = AuthTokenValidation.findOne();
|
||||
|
||||
if (!authenticationTokenValidation) return;
|
||||
@ -281,7 +272,7 @@ class Auth {
|
||||
initAnnotationsStreamListener();
|
||||
c.stop();
|
||||
clearTimeout(validationTimeout);
|
||||
resolve(true);
|
||||
setTimeout(() => resolve(true), 100);
|
||||
break;
|
||||
case ValidationStates.VALIDATING:
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user