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}
|
||||
};
|
||||
|
||||
this.logger.debug({obj}, `websocket: sending (${url})`);
|
||||
//this.logger.debug({obj}, `websocket: sending (${url})`);
|
||||
|
||||
/* simple notifications */
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -114,7 +116,9 @@ class WsRequestor extends BaseRequestor {
|
||||
});
|
||||
|
||||
/* 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.removeAllListeners();
|
||||
}
|
||||
|
||||
for (const [msgid, obj] of this.messagesInFlight) {
|
||||
obj.failure(`abandoning msgid ${msgid} since we have closed the socket`);
|
||||
}
|
||||
this.messagesInFlight.clear();
|
||||
|
||||
} catch (err) {
|
||||
this.logger.info({err}, 'WsRequestor: Error closing socket');
|
||||
}
|
||||
this.logger.info('WsRequestor:close socket closed');
|
||||
}
|
||||
|
||||
_connect() {
|
||||
@@ -222,7 +231,7 @@ class WsRequestor extends BaseRequestor {
|
||||
const obj = JSON.parse(content);
|
||||
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');
|
||||
|
||||
switch (type) {
|
||||
|
||||
Reference in New Issue
Block a user