@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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
|
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
|
-
|
|
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) {
|