mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
logging and cleanup
This commit is contained in:
@@ -80,11 +80,13 @@ class WsRequestor extends BaseRequestor {
|
|||||||
data: {...payload}
|
data: {...payload}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.logger.debug({obj}, `websocket: sending (${url})`);
|
//this.logger.debug({obj}, `websocket: sending (${url})`);
|
||||||
|
|
||||||
/* simple notifications */
|
/* simple notifications */
|
||||||
if (['call:status', 'jambonz:error'].includes(type)) {
|
if (['call:status', 'jambonz:error'].includes(type)) {
|
||||||
this.ws.send(JSON.stringify(obj));
|
this.ws.send(JSON.stringify(obj), () => {
|
||||||
|
this.logger.debug({obj}, `WsRequestor:request websocket: sent (${url})`);
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +116,9 @@ class WsRequestor extends BaseRequestor {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* send the message */
|
/* send the message */
|
||||||
this.ws.send(JSON.stringify(obj));
|
this.ws.send(JSON.stringify(obj), () => {
|
||||||
|
this.logger.debug({obj}, `WsRequestor:request websocket: sent (${url})`);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,10 +130,15 @@ class WsRequestor extends BaseRequestor {
|
|||||||
this.ws.close();
|
this.ws.close();
|
||||||
this.ws.removeAllListeners();
|
this.ws.removeAllListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const [msgid, obj] of this.messagesInFlight) {
|
||||||
|
obj.failure(`abandoning msgid ${msgid} since we have closed the socket`);
|
||||||
|
}
|
||||||
|
this.messagesInFlight.clear();
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.logger.info({err}, 'WsRequestor: Error closing socket');
|
this.logger.info({err}, 'WsRequestor: Error closing socket');
|
||||||
}
|
}
|
||||||
this.logger.info('WsRequestor:close socket closed');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_connect() {
|
_connect() {
|
||||||
@@ -222,7 +231,7 @@ class WsRequestor extends BaseRequestor {
|
|||||||
const obj = JSON.parse(content);
|
const obj = JSON.parse(content);
|
||||||
const {type, msgid, command, queueCommand = false, data} = obj;
|
const {type, msgid, command, queueCommand = false, data} = obj;
|
||||||
|
|
||||||
this.logger.debug({obj}, 'websocket: received');
|
this.logger.debug({obj}, 'WsRequestor:request websocket: received');
|
||||||
assert.ok(type, 'type property not supplied');
|
assert.ok(type, 'type property not supplied');
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|||||||
Reference in New Issue
Block a user