Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit d113d14

Browse files
committed
fix error when room is undefined
1 parent 593f5cf commit d113d14

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/http-api.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ export class HttpApi {
8989
getChannel(req: any, res: any): void {
9090
var channelName = req.params.channelName;
9191
var room = this.io.sockets.adapter.rooms[channelName];
92+
var subscriptionCount = room ? room.length : 0;
9293

9394
var result = {
94-
subscription_count: room.length,
95-
occupied: true
95+
subscription_count: subscriptionCount,
96+
occupied: !!subscriptionCount
9697
};
9798

9899
if (this.channel.isPresence(channelName)) {

0 commit comments

Comments
 (0)