From 24d4fd77a169f2340e22c06d18b9cca168a6cc4d Mon Sep 17 00:00:00 2001 From: John Sanders Date: Tue, 18 Oct 2022 15:00:26 -0400 Subject: [PATCH] fix: error handling when un/subscribe not supported --- src/sessionControlClient.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sessionControlClient.js b/src/sessionControlClient.js index a80fd9c..583cae3 100644 --- a/src/sessionControlClient.js +++ b/src/sessionControlClient.js @@ -688,6 +688,13 @@ class SessionControlClient extends EventEmitter { return; } + if (midGroupList[midGroup].subscribe === undefined) { + let err = new Error(`[Session Control Client] [Subscribe] subscribing to midGroup [${midGroup}] is not supported`); + debug("SessionControlClient _subscribe err_unsupported_midGroup"); + cb(err); + return; + } + let mid = opts || {}; let type = SUBSCRIBE; @@ -748,6 +755,13 @@ class SessionControlClient extends EventEmitter { return; } + if (midGroupList[midGroup].unsubscribe === undefined) { + let err = new Error(`[Session Control Client] [Unsubscribe] unsubscribing from midGroup [${midGroup}] is not supported`); + debug("SessionControlClient _unsubscribe err_unsupported_midGroup"); + cb(err); + return; + } + if (cb === undefined) { if (typeof opts === "function") { cb = opts;