fix crash from invalid online users
This commit is contained in:
parent
28cf3ec9cf
commit
cb58037ea1
@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger';
|
||||
import _ from 'lodash';
|
||||
|
||||
const COLLECTION_NAME = 'ping-pong';
|
||||
const POLL_INTERVAL = 5000;
|
||||
const POLL_INTERVAL = 15000;
|
||||
|
||||
function pingPong(credentials) {
|
||||
const { meetingId, requesterUserId } = credentials;
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { check } from 'meteor/check';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Users from '/imports/api/users';
|
||||
import setConnectionStatus from '/imports/api/users/server/modifiers/setConnectionStatus';
|
||||
import userJoin from '../methods/userJoin';
|
||||
|
||||
const clearOtherSessions = (sessionUserId, current = false) => {
|
||||
@ -54,7 +53,6 @@ export default function handleValidateAuthToken({ body }, meetingId) {
|
||||
if (valid) {
|
||||
const sessionUserId = `${meetingId}-${userId}`;
|
||||
const currentConnectionId = User.connectionId ? User.connectionId : false;
|
||||
setConnectionStatus(meetingId, userId);
|
||||
clearOtherSessions(sessionUserId, currentConnectionId);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ import { check } from 'meteor/check';
|
||||
import RedisPubSub from '/imports/startup/server/redis';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import Users from '/imports/api/users';
|
||||
import setConnectionStatus from '/imports/api/users/server/modifiers/setConnectionStatus';
|
||||
|
||||
export default function userLeaving(credentials, userId, connectionId) {
|
||||
const REDIS_CONFIG = Meteor.settings.private.redis;
|
||||
@ -38,6 +37,5 @@ export default function userLeaving(credentials, userId, connectionId) {
|
||||
};
|
||||
|
||||
Logger.info(`User '${userId}' is leaving meeting '${meetingId}'`);
|
||||
setConnectionStatus(meetingId, userId, 'offline');
|
||||
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import setMinBrowserVersions from './minBrowserVersion';
|
||||
import userLeaving from '/imports/api/users/server/methods/userLeaving';
|
||||
|
||||
const parse = Npm.require('url').parse;
|
||||
const INTERVAL_TIME = 10000;
|
||||
const INTERVAL_TIME = 30000;
|
||||
const AVAILABLE_LOCALES = fs.readdirSync('assets/app/locales');
|
||||
|
||||
Meteor.startup(() => {
|
||||
@ -49,19 +49,20 @@ Meteor.startup(() => {
|
||||
Logger.info('Checking for inactive users');
|
||||
const users = Users.find({
|
||||
connectionStatus: 'online',
|
||||
clientType: 'HTML5',
|
||||
lastPing: {
|
||||
$lt: (currentTime - INTERVAL_TIME), // get user who has not pinged in the last 10 seconds
|
||||
},
|
||||
loginTime: {
|
||||
$lt: (currentTime - INTERVAL_TIME),
|
||||
},
|
||||
}).fetch();
|
||||
if (!users.length) return Logger.info('No inactive users');
|
||||
Logger.info('Removing inactive users');
|
||||
users.forEach((user) => {
|
||||
const loginTimeDelta = currentTime - user.loginTime;
|
||||
const lastPingDelta = currentTime - user.lastPing;
|
||||
Logger.info(`Detected inactive user, userId:${user.userId}, meetingId:${user.meetingId}`);
|
||||
user.requesterUserId = user.userId;
|
||||
return loginTimeDelta >= INTERVAL_TIME
|
||||
&& lastPingDelta >= INTERVAL_TIME
|
||||
&& userLeaving(user, user.userId, user.connectionId);
|
||||
return userLeaving(user, user.userId, user.connectionId);
|
||||
});
|
||||
return Logger.info('All inactive user have been removed');
|
||||
}, INTERVAL_TIME);
|
||||
|
Loading…
Reference in New Issue
Block a user