mirror of
https://github.com/nvms/prsm.git
synced 2025-12-15 15:50:53 +00:00
add getRoomsForConnection
This commit is contained in:
parent
af2cf5a4a4
commit
6bd9803c61
@ -67,6 +67,21 @@ export class RoomManager {
|
||||
await this.redis.sadd(this.connectionsRoomKey(connectionId), roomName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of rooms that the specified connection is currently a member of.
|
||||
*
|
||||
* @param {Connection | string} connection - The connection object or connection ID for which to retrieve room memberships.
|
||||
* @returns {Promise<string[]>} A promise that resolves to an array of room names associated with the connection.
|
||||
* @throws {Error} If the underlying Redis operation fails, the promise will be rejected with an error.
|
||||
*/
|
||||
async getRoomsForConnection(
|
||||
connection: Connection | string
|
||||
): Promise<string[]> {
|
||||
const connectionId =
|
||||
typeof connection === "string" ? connection : connection.id;
|
||||
return await this.redis.smembers(this.connectionsRoomKey(connectionId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a connection from a specified room and updates Redis accordingly.
|
||||
* Accepts either a Connection object or a string representing the connection ID.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user