@jusbid/redis 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -2
- package/package.json +4 -2
- package/socket-manager.js +1 -1
package/index.js
CHANGED
|
@@ -10,7 +10,8 @@ const {
|
|
|
10
10
|
|
|
11
11
|
const { initSocketManager, getIO, emitEvent, emitWithAck } = require("./socket-manager");
|
|
12
12
|
const { SOCKET_EVENTS } = require('./redis-client');
|
|
13
|
-
const { Server } = require("socket.io")
|
|
13
|
+
const { Server } = require("socket.io");
|
|
14
|
+
const { createAdapter } = require("@socket.io/redis-adapter");
|
|
14
15
|
|
|
15
16
|
const redisOptions = {};
|
|
16
17
|
|
|
@@ -910,7 +911,11 @@ const createSocketServer = ({
|
|
|
910
911
|
pingTimeout: 25000,
|
|
911
912
|
pingInterval: 20000, // good to set explicitly too
|
|
912
913
|
});
|
|
913
|
-
|
|
914
|
+
|
|
915
|
+
// ✅ FIX: Attach Redis Adapter for multi-instance room sharing
|
|
916
|
+
// initRedisClients() must be called before createSocketServer()
|
|
917
|
+
const { pubClient, subClient } = getRedisClients();
|
|
918
|
+
socketServer.adapter(createAdapter(pubClient, subClient));
|
|
914
919
|
|
|
915
920
|
// Token handshake middleware
|
|
916
921
|
socketServer.use(async (socket, next) => {
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jusbid/redis",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"redis": "^4.6.13",
|
|
8
|
-
"@jusbid/logger": "1.0.0"
|
|
8
|
+
"@jusbid/logger": "1.0.0",
|
|
9
|
+
"@socket.io/redis-adapter": "^8.3.0",
|
|
10
|
+
"socket.io": "^4.7.5"
|
|
9
11
|
},
|
|
10
12
|
"publishConfig": {
|
|
11
13
|
"access": "public"
|
package/socket-manager.js
CHANGED
|
@@ -24,7 +24,7 @@ const getIO = () => {
|
|
|
24
24
|
* Emit from anywhere, without needing direct io access
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
|
-
const emitEvent = async (event, data
|
|
27
|
+
const emitEvent = async (room, event, data) => {
|
|
28
28
|
const io = getIO();
|
|
29
29
|
if (room) {
|
|
30
30
|
const sockets = await io.in(room).fetchSockets(); // works across Redis Adapter instances too
|