From 06967a1c25c51477f9864ede1c024e05fe05dbfa Mon Sep 17 00:00:00 2001 From: patrikx3 Date: Thu, 25 Apr 2024 02:46:27 +0200 Subject: [PATCH] r0b08x [chore] 4/25/2024, 2:46:27 AM --- README.md | 4 ++-- artifacts/cluster.md | 2 +- package.json | 2 +- .../socket.io/request/set-subscription.js | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8dd64bd..f17b5e9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ https://corifeus.com/redis-ui --- -# 🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface v2024.4.221 +# 🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface v2024.4.223 @@ -112,7 +112,7 @@ All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https:// --- -[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.221 +[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.223 [![NPM](https://img.shields.io/npm/v/p3x-redis-ui-server.svg)](https://www.npmjs.com/package/p3x-redis-ui-server) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/artifacts/cluster.md b/artifacts/cluster.md index eaa8d50..c6d8fbd 100644 --- a/artifacts/cluster.md +++ b/artifacts/cluster.md @@ -25,7 +25,7 @@ All my domains ([patrikx3.com](https://patrikx3.com) and [corifeus.com](https:// --- -[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.221 +[**P3X-REDIS-UI-SERVER**](https://corifeus.com/redis-ui-server) Build v2024.4.223 [![NPM](https://img.shields.io/npm/v/p3x-redis-ui-server.svg)](https://www.npmjs.com/package/p3x-redis-ui-server) [![Donate for Corifeus / P3X](https://img.shields.io/badge/Donate-Corifeus-003087.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZVM4V6HVZJW6) [![Contact Corifeus / P3X](https://img.shields.io/badge/Contact-P3X-ff9900.svg)](https://www.patrikx3.com/en/front/contact) [![Like Corifeus @ Facebook](https://img.shields.io/badge/LIKE-Corifeus-3b5998.svg)](https://www.facebook.com/corifeus.software) diff --git a/package.json b/package.json index 1d0d15b..f1469ff 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p3x-redis-ui-server", - "version": "2024.4.221", + "version": "2024.4.223", "description": "🏍️ The p3x-redis-ui-server package motor that is connected to the p3x-redis-ui-material web user interface", "corifeus": { "icon": "fas fa-flag-checkered", diff --git a/src/service/socket.io/request/set-subscription.js b/src/service/socket.io/request/set-subscription.js index 2a0e092..a4495a7 100644 --- a/src/service/socket.io/request/set-subscription.js +++ b/src/service/socket.io/request/set-subscription.js @@ -2,13 +2,13 @@ module.exports = async (options) => { const { socket, payload } = options; try { - if (socket.p3xrs && socket.p3xrs.subscription) { - // Unsubscribe before clearing the old listener to prevent memory leaks - await socket.p3xrs.ioredisSubscriber.punsubscribe('*'); + //console.log('Unsubscribing from all patterns'); + await socket.p3xrs.ioredisSubscriber.punsubscribe(); + //console.log('All patterns unsubscribed'); + + socket.p3xrs.ioredisSubscriber.removeAllListeners('pmessage'); + //console.log('Removed all pmessage listeners'); - // Remove old listeners to prevent multiple listeners from accumulating - socket.p3xrs.ioredisSubscriber.removeAllListeners('pmessage'); - } // Updating subscription settings socket.p3xrs.subscription = payload.subscription; @@ -18,13 +18,13 @@ module.exports = async (options) => { if (socket.p3xrs.subscription === true) { // Subscribe to the pattern + //console.log('socket.p3xrs.ioredisSubscriber.psubscribe', payload.subscriberPattern) await socket.p3xrs.ioredisSubscriber.psubscribe(payload.subscriberPattern); - console.log('socket.p3xrs.subscription', payload.subscriberPattern) // Handle incoming messages socket.p3xrs.ioredisSubscriber.on('pmessage', (pattern, channel, message) => { - //console.log('subscription', pattern, channel, message) + console.log('socket.p3xrs.ioredisSubscriber.on(pmessage)', pattern, channel, message) socket.emit('pubsub-message', { channel: channel, message: message,