ws manager uses password
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
"start": "node lib/index.js",
|
"start": "node lib/index.js",
|
||||||
"dev": "ts-node src/index.ts",
|
"dev": "ts-node src/index.ts",
|
||||||
"ws-publish": "ts-node src/wsPublish.ts",
|
"ws-publish": "ts-node src/wsPublish.ts",
|
||||||
"manager": "ts-node src/wsConnectionManager.ts",
|
"ws-manager": "ts-node src/wsConnectionManager.ts",
|
||||||
"dev:inspect": "yarn build && node --inspect ./lib/index.js",
|
"dev:inspect": "yarn build && node --inspect ./lib/index.js",
|
||||||
"dev:debug": "yarn build && node --inspect-brk --inspect=2230 ./lib/index.js",
|
"dev:debug": "yarn build && node --inspect-brk --inspect=2230 ./lib/index.js",
|
||||||
"example": "ts-node example/client.ts",
|
"example": "ts-node example/client.ts",
|
||||||
|
|||||||
@@ -16,9 +16,10 @@ const io = new Server(server);
|
|||||||
|
|
||||||
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
const REDIS_HOST = process.env.REDIS_HOST || 'localhost';
|
||||||
const REDIS_PORT = process.env.REDIS_PORT || '6379';
|
const REDIS_PORT = process.env.REDIS_PORT || '6379';
|
||||||
|
const REDIS_PASSWORD = process.env.REDIS_PASSWORD;
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT);
|
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
||||||
await redisClient.connect();
|
await redisClient.connect();
|
||||||
|
|
||||||
io.on('connection', (socket) => {
|
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', () => {
|
server.listen('3000', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user