@mulingai-npm/redis 3.11.0 → 3.13.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.
|
@@ -18,8 +18,8 @@ export declare class MulingstreamListenerManager {
|
|
|
18
18
|
getListenersByRoom(roomId: string): Promise<MulingstreamListenerData[]>;
|
|
19
19
|
getListener(listenerIdOrToken: string): Promise<MulingstreamListenerData | null>;
|
|
20
20
|
removeListenerByToken(token: string): Promise<boolean>;
|
|
21
|
-
updateNameLanguage(listenerIdOrToken: string, name: string, language: string): Promise<
|
|
22
|
-
updateSocketId(listenerIdOrToken: string, socketId: string): Promise<
|
|
21
|
+
updateNameLanguage(listenerIdOrToken: string, name: string, language: string): Promise<MulingstreamListenerData | null>;
|
|
22
|
+
updateSocketId(listenerIdOrToken: string, socketId: string): Promise<MulingstreamListenerData | null>;
|
|
23
23
|
getTargetSocketIdsByRoomLanguage(roomId: string, language: string): Promise<string[]>;
|
|
24
24
|
getUniqueLanguagesByRoom(roomId: string): Promise<string[]>;
|
|
25
25
|
}
|
|
@@ -112,25 +112,25 @@ class MulingstreamListenerManager {
|
|
|
112
112
|
async updateNameLanguage(listenerIdOrToken, name, language) {
|
|
113
113
|
const listener = await this.getListener(listenerIdOrToken);
|
|
114
114
|
if (!listener) {
|
|
115
|
-
return
|
|
115
|
+
return null;
|
|
116
116
|
}
|
|
117
117
|
// Update the name/language on the listener’s hash key
|
|
118
118
|
await this.redisClient.hset(`listener:${listener.listenerId}`, {
|
|
119
119
|
name,
|
|
120
120
|
language
|
|
121
121
|
});
|
|
122
|
-
return
|
|
122
|
+
return { ...listener, name, language };
|
|
123
123
|
}
|
|
124
124
|
async updateSocketId(listenerIdOrToken, socketId) {
|
|
125
125
|
const listener = await this.getListener(listenerIdOrToken);
|
|
126
126
|
if (!listener) {
|
|
127
|
-
return
|
|
127
|
+
return null;
|
|
128
128
|
}
|
|
129
129
|
// Update the name/language on the listener’s hash key
|
|
130
130
|
await this.redisClient.hset(`listener:${listener.listenerId}`, {
|
|
131
131
|
socketId
|
|
132
132
|
});
|
|
133
|
-
return
|
|
133
|
+
return { ...listener, socketId };
|
|
134
134
|
}
|
|
135
135
|
async getTargetSocketIdsByRoomLanguage(roomId, language) {
|
|
136
136
|
const listeners = await this.getListenersByRoom(roomId);
|
|
@@ -134,27 +134,19 @@ class MulingstreamSpeakerManager {
|
|
|
134
134
|
return null;
|
|
135
135
|
}
|
|
136
136
|
async getSpeakersByRoomId(roomId) {
|
|
137
|
-
console.log(`🔍 [getSpeakersByRoomId] Looking for speakers in room: ${roomId}`);
|
|
138
137
|
const ids = await this.redisClient.smembers(`room:${roomId}:speakers`);
|
|
139
|
-
console.log(`🔍 [getSpeakersByRoomId] Found speaker IDs in room index:`, ids);
|
|
140
138
|
const result = [];
|
|
141
139
|
for (const id of ids) {
|
|
142
|
-
console.log(`🔍 [getSpeakersByRoomId] Processing speaker ID: ${id}`);
|
|
143
140
|
const key = this.buildKey(id);
|
|
144
|
-
console.log(`🔍 [getSpeakersByRoomId] Generated key: ${key}`);
|
|
145
141
|
const hash = await this.redisClient.hgetall(key);
|
|
146
|
-
console.log(`🔍 [getSpeakersByRoomId] Retrieved hash for ${id}:`, hash);
|
|
147
142
|
if (hash !== null && Object.keys(hash).length > 0) {
|
|
148
143
|
const parsedSpeaker = this.parseHash(hash);
|
|
149
|
-
console.log(`✅ [getSpeakersByRoomId] Successfully parsed speaker:`, parsedSpeaker);
|
|
150
144
|
result.push(parsedSpeaker);
|
|
151
145
|
}
|
|
152
146
|
else {
|
|
153
|
-
console.log(`⚠️ [getSpeakersByRoomId] Speaker ${id} not found or empty, cleaning indexes`);
|
|
154
147
|
await this.cleanIndexes(id);
|
|
155
148
|
}
|
|
156
149
|
}
|
|
157
|
-
console.log(`🔍 [getSpeakersByRoomId] Final result for room ${roomId}:`, result);
|
|
158
150
|
return result;
|
|
159
151
|
}
|
|
160
152
|
async getSpeakersByUserId(userId) {
|