mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
Feature/config verb (#77)
* remove cognigy verb * initial implementation of config verb * further updates to config * Bot mode alex (#75) * do not use default as value for TTS/STT * fix gather listener if no say or play provided Co-authored-by: akirilyuk <a.kirilyuk@cognigy.com> * gather: listenDuringPrompt requires a nested play/say * fix exception * say: fix exception where caller hangs up during say * bugfix: sip refer was not ending if caller hungup during refer * add support for sip:request to ws commands * gather: when bargein is set and minBargeinWordCount is zero, kill audio on endOfUtterrance * gather/transcribe: add support for google boost and azure custom endpoints * minor logging changes * lint error Co-authored-by: akirilyuk <45361199+akirilyuk@users.noreply.github.com> Co-authored-by: akirilyuk <a.kirilyuk@cognigy.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
"TaskName": {
|
||||
"Cognigy": "cognigy",
|
||||
"Conference": "conference",
|
||||
"Config": "config",
|
||||
"Dequeue": "dequeue",
|
||||
"Dial": "dial",
|
||||
"Dialogflow": "dialogflow",
|
||||
|
||||
@@ -14,6 +14,7 @@ class WsRequestor extends BaseRequestor {
|
||||
this.connections = 0;
|
||||
this.messagesInFlight = new Map();
|
||||
this.maliciousClient = false;
|
||||
this.closedByUs = false;
|
||||
|
||||
assert(this._isAbsoluteUrl(this.url));
|
||||
|
||||
@@ -44,7 +45,7 @@ class WsRequestor extends BaseRequestor {
|
||||
|
||||
/* if we have an absolute url, and it is http then do a standard webhook */
|
||||
if (this._isAbsoluteUrl(url) && url.startsWith('http')) {
|
||||
this.logger.debug({hook}, 'WsRequestor: sending a webhook');
|
||||
this.logger.debug({hook}, 'WsRequestor: sending a webhook (HTTP)');
|
||||
const requestor = new HttpRequestor(this.logger, this.account_sid, hook, this.secret);
|
||||
return requestor.request(type, hook, params);
|
||||
}
|
||||
@@ -79,7 +80,7 @@ class WsRequestor extends BaseRequestor {
|
||||
data: {...payload}
|
||||
};
|
||||
|
||||
this.logger.debug({obj}, `WsRequestor:request ${url}`);
|
||||
this.logger.debug({obj}, `websocket: sending (${url})`);
|
||||
|
||||
/* simple notifications */
|
||||
if (['call:status', 'jambonz:error'].includes(type)) {
|
||||
@@ -118,11 +119,17 @@ class WsRequestor extends BaseRequestor {
|
||||
}
|
||||
|
||||
close() {
|
||||
this.logger.info('WsRequestor: closing socket');
|
||||
if (this.ws) {
|
||||
this.ws.close();
|
||||
this.ws.removeAllListeners();
|
||||
this.logger.info('WsRequestor:close closing socket');
|
||||
this.closedByUs = true;
|
||||
try {
|
||||
if (this.ws) {
|
||||
this.ws.close();
|
||||
this.ws.removeAllListeners();
|
||||
}
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'WsRequestor: Error closing socket');
|
||||
}
|
||||
this.logger.info('WsRequestor:close socket closed');
|
||||
}
|
||||
|
||||
_connect() {
|
||||
@@ -197,13 +204,8 @@ class WsRequestor extends BaseRequestor {
|
||||
|
||||
_onSocketClosed() {
|
||||
this.ws = null;
|
||||
if (this.connections > 0) {
|
||||
if (this.connections < MAX_RECONNECTS) {
|
||||
setTimeout(this._connect.bind(this), 500);
|
||||
}
|
||||
else {
|
||||
this.logger.info('WsRequestor:_onSocketClosed - max reconnection attempts reached');
|
||||
}
|
||||
if (this.connections > 0 && this.connections < MAX_RECONNECTS && !this.closedByUs) {
|
||||
setTimeout(this._connect.bind(this), 500);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +219,10 @@ class WsRequestor extends BaseRequestor {
|
||||
|
||||
/* messages must be JSON format */
|
||||
try {
|
||||
const {type, msgid, command, queueCommand = false, data} = JSON.parse(content);
|
||||
const obj = JSON.parse(content);
|
||||
const {type, msgid, command, queueCommand = false, data} = obj;
|
||||
|
||||
this.logger.debug({obj}, 'websocket: received');
|
||||
assert.ok(type, 'type property not supplied');
|
||||
|
||||
switch (type) {
|
||||
|
||||
Reference in New Issue
Block a user