@mulingai-npm/redis 3.10.1 → 3.12.0

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.
@@ -62,13 +62,24 @@ class MulingstreamSpeakerManager {
62
62
  speakerId,
63
63
  timestamp: new Date(Date.now()).toISOString()
64
64
  };
65
- await this.redisClient.hset(key, this.serialize(speakerData));
66
- await this.redisClient.expire(key, EXPIRATION);
67
- await this.redisClient.sadd(`room:${payload.roomId}:speakers`, speakerId);
68
- await this.redisClient.sadd(`user:${payload.userId}:speakers`, speakerId);
69
- await this.redisClient.set(`socket:${payload.socketId}:speaker`, speakerId);
70
- await this.redisClient.expire(`socket:${payload.socketId}:speaker`, EXPIRATION);
71
- return speakerId;
65
+ try {
66
+ // Store main speaker hash
67
+ const serializedData = this.serialize(speakerData);
68
+ await this.redisClient.hset(key, serializedData);
69
+ await this.redisClient.expire(key, EXPIRATION);
70
+ // Add to room index
71
+ await this.redisClient.sadd(`room:${payload.roomId}:speakers`, speakerId);
72
+ // Add to user index
73
+ await this.redisClient.sadd(`user:${payload.userId}:speakers`, speakerId);
74
+ // Create socket mapping
75
+ await this.redisClient.set(`socket:${payload.socketId}:speaker`, speakerId);
76
+ await this.redisClient.expire(`socket:${payload.socketId}:speaker`, EXPIRATION);
77
+ return speakerId;
78
+ }
79
+ catch (error) {
80
+ console.error('❌ [addSpeaker] Error during speaker registration:', error);
81
+ throw error;
82
+ }
72
83
  }
73
84
  async removeSpeakerBySocketId(socketId) {
74
85
  const speakerId = await this.redisClient.get(`socket:${socketId}:speaker`);
@@ -126,14 +137,17 @@ class MulingstreamSpeakerManager {
126
137
  const ids = await this.redisClient.smembers(`room:${roomId}:speakers`);
127
138
  const result = [];
128
139
  for (const id of ids) {
129
- const hash = await this.redisClient.hgetall(this.buildKey(id));
140
+ const key = this.buildKey(id);
141
+ const hash = await this.redisClient.hgetall(key);
130
142
  if (hash !== null && Object.keys(hash).length > 0) {
131
- result.push(this.parseHash(hash));
143
+ const parsedSpeaker = this.parseHash(hash);
144
+ result.push(parsedSpeaker);
132
145
  }
133
146
  else {
134
147
  await this.cleanIndexes(id);
135
148
  }
136
149
  }
150
+ console.log(`🔍 [getSpeakersByRoomId] Final result for room ${roomId}:`, result);
137
151
  return result;
138
152
  }
139
153
  async getSpeakersByUserId(userId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "3.10.1",
3
+ "version": "3.12.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {