Registry / messaging / node-redis-room

node-redis-room

JSON →
library0.1.1jsnpmunverified

A library for using Socket.IO rooms and namespaces across multiple Node.js processes via Redis. Version 0.1.1 (unmaintained). It provides a Redis-backed pub/sub mechanism to synchronize room membership, broadcasts, and user tracking in clustered Socket.IO deployments. Key differentiators: simple API for joining/leaving rooms, broadcasting, and querying room members across nodes. However, it is outdated and relies on Socket.IO v0.9.x, incompatible with modern Socket.IO versions.

npm install node-redis-room
INSTALL
IMPORT
SIG · NODE-REDIS-ROOM
N
node-redis-room
messagingjavascriptv0.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

nodeRedisRoom
const nodeRedisRoom = require('node-redis-room');
import nodeRedisRoom from 'node-redis-room';
Package exports a single CommonJS module; no ESM support.
init
nodeRedisRoom.init(io, crud, sub, pub);
Must call init() before any other method; do not call inside socket 'connect' event.
join
nodeRedisRoom.join(socket, roomName, userObj, callback);
userObj must contain 'id' and 'connectionId' fields.

Initializes node-redis-room with Socket.IO and Redis, joins a socket to a room, broadcasts a join event, handles disconnect, and queries room members.

const io = require('socket.io')(3000); const redis = require('redis'); const nodeRedisRoom = require('node-redis-room'); const crud = redis.createClient(); const sub = redis.createClient(); const pub = redis.createClient(); nodeRedisRoom.init(io, crud, sub, pub); io.on('connection', (socket) => { const user = { id: 'user123', connectionId: socket.id, nick: 'foo', avatar: '' }; nodeRedisRoom.join(socket, 'room1', user, (err) => { if (err) console.error(err); else console.log('User joined room1'); }); nodeRedisRoom.broadcast('room1', { cmd: 'join', content: user }); socket.on('disconnect', () => { nodeRedisRoom.onDisconnect(user, () => {}); }); }); setTimeout(() => { nodeRedisRoom.getRoomMembers('room1', (err, users) => { console.log('Room members:', users); }); }, 1000);
Debug
Known issues
breakingPackage is designed for Socket.IO v0.9.x and is incompatible with Socket.IO v1.x and later due to API changes.
fix
Use socket.io-redis or modern clustering solutions.
affects: >=1.0
deprecatedThe library has not been updated since 2013 and is effectively abandoned.
fix
Consider socket.io-redis for Redis-based Socket.IO clustering.
affects: >=0.0
gotchainit() must not be called inside the socket 'connect' event; otherwise, it will reinitialize and break existing rooms.
fix
Call init() once at application startup, not per-connection.
affects: >=0.0
gotchaThe user object passed to join() and onDisconnect() must have both 'id' and 'connectionId' fields or the library will crash.
fix
Always include 'id' and 'connectionId' in the user object.
affects: >=0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'join' of undefined
init() not called before join() or init() called multiple times
fix
Ensure nodeRedisRoom.init(io, crud, sub, pub) is called once at startup before any socket events.
socket is not defined
Attempting to use nodeRedisRoom methods outside of a socket callback without a valid socket object
fix
Only call join() or leave() within a socket 'connection' event handler using the socket parameter.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies
redisrequiredRequired for Redis client, subscriber, and publisher connections
socket.iorequiredPeer dependency for Socket.IO integration (v0.9.x)
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
node-redis-room — npm install node-redis-room · libregistry