Spaces:
Running
Running
File size: 464 Bytes
c4341fd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | const { getIO } = require('./io');
const kickSessions = (username, predicate) => {
const io = getIO();
if (!io || !username) return;
for (const [, s] of io.sockets.sockets) {
if (s.username !== username) continue;
if (predicate && !predicate(s.authToken)) continue;
try { s.emit('session_revoked'); } catch {}
setTimeout(() => { try { s.disconnect(true); } catch {} }, 50);
}
};
module.exports = { kickSessions };
|