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

Commit 66bbbc5

Browse files
authored
Merge pull request #194 from hosmelq/master
fix error when room is undefined
2 parents 51a39cb + d113d14 commit 66bbbc5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/api/http-api.ts

+3-2
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)