@mulingai-npm/redis 3.6.0 → 3.7.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.
@@ -1,5 +1,6 @@
1
1
  export declare enum RedisDatabase {
2
2
  MULINGSTREAM_LISTENER = 0,
3
3
  MULINGSTREAM_CHUNK = 1,
4
- MULINGSTREAM_SPEAKER = 2
4
+ MULINGSTREAM_SPEAKER = 2,
5
+ CONTENT_DATA = 3
5
6
  }
@@ -6,4 +6,5 @@ var RedisDatabase;
6
6
  RedisDatabase[RedisDatabase["MULINGSTREAM_LISTENER"] = 0] = "MULINGSTREAM_LISTENER";
7
7
  RedisDatabase[RedisDatabase["MULINGSTREAM_CHUNK"] = 1] = "MULINGSTREAM_CHUNK";
8
8
  RedisDatabase[RedisDatabase["MULINGSTREAM_SPEAKER"] = 2] = "MULINGSTREAM_SPEAKER";
9
+ RedisDatabase[RedisDatabase["CONTENT_DATA"] = 3] = "CONTENT_DATA";
9
10
  })(RedisDatabase = exports.RedisDatabase || (exports.RedisDatabase = {}));
@@ -21,9 +21,5 @@ export declare class MulingstreamListenerManager {
21
21
  updateNameLanguage(listenerIdOrToken: string, name: string, language: string): Promise<boolean>;
22
22
  updateSocketId(listenerIdOrToken: string, socketId: string): Promise<boolean>;
23
23
  getTargetSocketIdsByRoomLanguage(roomId: string, language: string): Promise<string[]>;
24
- /**
25
- * Returns an array of unique languages for the given room, from highest frequency to lowest.
26
- * If a listener has no language (empty string / undefined), it is ignored.
27
- */
28
24
  getUniqueLanguagesByRoom(roomId: string): Promise<string[]>;
29
25
  }
@@ -139,10 +139,6 @@ class MulingstreamListenerManager {
139
139
  });
140
140
  return filteredListeners.map((listener) => listener.socketId);
141
141
  }
142
- /**
143
- * Returns an array of unique languages for the given room, from highest frequency to lowest.
144
- * If a listener has no language (empty string / undefined), it is ignored.
145
- */
146
142
  async getUniqueLanguagesByRoom(roomId) {
147
143
  // 1) Fetch all listeners for the room.
148
144
  // (This includes inactive ones, but feel free to filter out isActive === false if you only want active ones.)
@@ -15,11 +15,7 @@ export declare class MulingstreamSpeakerManager {
15
15
  private redisClient;
16
16
  constructor(redisClient: RedisClient);
17
17
  private buildLockKey;
18
- /** Try to claim the speaker slot for this room.
19
- * @returns true when the lock was acquired, false if someone else holds it.
20
- */
21
18
  acquireRoomLock(roomId: string, socketId: string, ttl?: number): Promise<boolean>;
22
- /** Release the lock if we still own it. */
23
19
  releaseRoomLock(roomId: string, socketId: string): Promise<void>;
24
20
  private parseHash;
25
21
  private serialize;
@@ -7,19 +7,12 @@ class MulingstreamSpeakerManager {
7
7
  constructor(redisClient) {
8
8
  this.redisClient = redisClient;
9
9
  }
10
- /* ------------------------------------------------------------------ */
11
- /* One-speaker-per-room locking helpers */
12
- /* ------------------------------------------------------------------ */
13
10
  buildLockKey(roomId) {
14
11
  return `room:${roomId}:speaker_lock`;
15
12
  }
16
- /** Try to claim the speaker slot for this room.
17
- * @returns true when the lock was acquired, false if someone else holds it.
18
- */
19
13
  async acquireRoomLock(roomId, socketId, ttl = LOCK_TTL) {
20
14
  return this.redisClient.setNxEx(this.buildLockKey(roomId), socketId, ttl);
21
15
  }
22
- /** Release the lock if we still own it. */
23
16
  async releaseRoomLock(roomId, socketId) {
24
17
  const lockKey = this.buildLockKey(roomId);
25
18
  const current = await this.redisClient.get(lockKey);
@@ -27,9 +20,6 @@ class MulingstreamSpeakerManager {
27
20
  await this.redisClient.del(lockKey);
28
21
  }
29
22
  }
30
- /* ------------------------------------------------------------------ */
31
- /* Speaker CRUD + queries */
32
- /* ------------------------------------------------------------------ */
33
23
  parseHash(hash) {
34
24
  return {
35
25
  speakerId: hash.speakerId,
@@ -210,7 +200,7 @@ class MulingstreamSpeakerManager {
210
200
  this.redisClient.srem(`room:${roomId}:speakers`, speakerId),
211
201
  this.redisClient.srem(`user:${userId}:speakers`, speakerId),
212
202
  this.redisClient.del(`socket:${socketId}:speaker`),
213
- this.redisClient.del(this.buildLockKey(roomId)) // ensure lock clears
203
+ this.redisClient.del(this.buildLockKey(roomId))
214
204
  ]);
215
205
  }
216
206
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {