From d113d1459d79f749a65cea3677e80f49e7c442e7 Mon Sep 17 00:00:00 2001 From: Hosmel Quintana Date: Thu, 3 Aug 2017 18:11:18 -0600 Subject: [PATCH] fix error when room is undefined --- src/api/http-api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/http-api.ts b/src/api/http-api.ts index b43b85ed..9d1895da 100644 --- a/src/api/http-api.ts +++ b/src/api/http-api.ts @@ -89,10 +89,11 @@ export class HttpApi { getChannel(req: any, res: any): void { var channelName = req.params.channelName; var room = this.io.sockets.adapter.rooms[channelName]; + var subscriptionCount = room ? room.length : 0; var result = { - subscription_count: room.length, - occupied: true + subscription_count: subscriptionCount, + occupied: !!subscriptionCount }; if (this.channel.isPresence(channelName)) {