From 8c5cdd374be68cef686dd8db69e41b77449a9fc5 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Thu, 10 Mar 2022 10:52:48 -0500 Subject: [PATCH] ws command can have call_id --- lib/session/call-session.js | 8 ++++---- lib/utils/ws-requestor.js | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/session/call-session.js b/lib/session/call-session.js index 908d85d0..70638f85 100644 --- a/lib/session/call-session.js +++ b/lib/session/call-session.js @@ -726,7 +726,7 @@ class CallSession extends Emitter { this.taskIdx = 0; } - _onCommand({msgid, command, queueCommand, data}) { + _onCommand({msgid, command, call_sid, queueCommand, data}) { this.logger.info({msgid, command, queueCommand}, 'CallSession:_onCommand - received command'); switch (command) { case 'redirect': @@ -751,7 +751,7 @@ class CallSession extends Emitter { break; case 'mute:status': - this._lccMuteStatus(this.callSid, data); + this._lccMuteStatus(call_sid, data); break; case 'conf:mute-status': @@ -767,11 +767,11 @@ class CallSession extends Emitter { break; case 'whisper': - this._lccWhisper(data, this.callSid); + this._lccWhisper(data, call_sid); break; case 'sip:request': - this._lccSipRequest(data, this.callSid) + this._lccSipRequest(data, call_sid) .catch((err) => { this.logger.info({err, data}, `CallSession:_onCommand - error sending ${data.method}`); }); diff --git a/lib/utils/ws-requestor.js b/lib/utils/ws-requestor.js index 1d15ef19..45319855 100644 --- a/lib/utils/ws-requestor.js +++ b/lib/utils/ws-requestor.js @@ -229,7 +229,7 @@ class WsRequestor extends BaseRequestor { /* messages must be JSON format */ try { const obj = JSON.parse(content); - const {type, msgid, command, queueCommand = false, data} = obj; + const {type, msgid, command, call_sid = this.call_sid, queueCommand = false, data} = obj; this.logger.debug({obj}, 'WsRequestor:request websocket: received'); assert.ok(type, 'type property not supplied'); @@ -243,7 +243,7 @@ class WsRequestor extends BaseRequestor { case 'command': assert.ok(command, 'command property not supplied'); assert.ok(data, 'data property not supplied'); - this._recvCommand(msgid, command, queueCommand, data); + this._recvCommand(msgid, command, call_sid, queueCommand, data); break; default: @@ -266,10 +266,10 @@ class WsRequestor extends BaseRequestor { success && success(data); } - _recvCommand(msgid, command, queueCommand, data) { + _recvCommand(msgid, command, call_sid, queueCommand, data) { // TODO: validate command - this.logger.info({msgid, command, queueCommand, data}, 'received command'); - this.emit('command', {msgid, command, queueCommand, data}); + this.logger.info({msgid, command, call_sid, queueCommand, data}, 'received command'); + this.emit('command', {msgid, command, call_sid, queueCommand, data}); } }