p3x-redis-ui-server
Version:
🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface
35 lines (28 loc) • 912 B
JavaScript
const sharedIoRedis = require('../shared')
const consolePrefix = 'socket.io connection disconnect'
module.exports = async (options) => {
const {socket, payload} = options;
const {connectionId} = payload;
console.warn(consolePrefix, 'connectionId', connectionId, 'socket.p3xrs.connectionId', socket.p3xrs.connectionId)
try {
if (socket.p3xrs.connectionId === connectionId) {
console.warn(consolePrefix, 'will disconnect from redis')
sharedIoRedis.disconnectRedis({
socket: socket,
})
}
socket.emit(options.responseEvent, {
status: 'ok',
})
} catch (e) {
console.error(e)
socket.emit(options.responseEvent, {
status: 'error',
error: e.message
})
} finally {
sharedIoRedis.sendStatus({
socket: socket,
})
}
}