ws manager uses password

This commit is contained in:
Nour Alharithi
2023-10-27 17:09:19 -07:00
parent d5f1584bef
commit cc8fe46ad2
2 changed files with 13 additions and 2 deletions

View File

@@ -16,9 +16,10 @@ const io = new Server(server);
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
const REDIS_PORT = process.env.REDIS_PORT || '6379';
const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
async function main() {
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT);
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
await redisClient.connect();
io.on('connection', (socket) => {
@@ -31,6 +32,16 @@ async function main() {
}
});
});
socket.on('unsubscribe', (channel) => {
console.log('Unsubscribing from channel', channel);
redisClient.client.unsubscribe(channel);
});
socket.on('disconnect', () => {
console.log('Client disconnected');
});
});
server.listen('3000', () => {