initial working version with ws api

This commit is contained in:
Dave Horton
2022-02-21 18:17:43 -05:00
parent 06e36ddd00
commit 1bac632a35
2 changed files with 77 additions and 21 deletions

View File

@@ -196,7 +196,7 @@ class WsRequestor extends BaseRequestor {
/* messages must be JSON format */
try {
const {type, msgid, command, call_sid, data} = JSON.parse(content);
const {type, msgid, command, data} = JSON.parse(content);
assert.ok(type, 'type property not supplied');
switch (type) {
@@ -207,9 +207,8 @@ class WsRequestor extends BaseRequestor {
case 'command':
assert.ok(command, 'command property not supplied');
assert.ok(call_sid, 'call_sid property not supplied');
assert.ok(data, 'data property not supplied');
this._recvCommand(msgid, command, call_sid, data);
this._recvCommand(msgid, command, data);
break;
default:
@@ -232,8 +231,10 @@ class WsRequestor extends BaseRequestor {
success && success(data);
}
_recvCommand(msgid, command, call_sid, data) {
// TODO: execute command
_recvCommand(msgid, command, data) {
// TODO: validate command
this.logger.info({msgid, command, data}, 'received command');
this.emit('command', {msgid, command, data});
}
}