drachtio-srf 5.0.21 → 5.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/drachtio-agent.js +31 -4
- package/package.json +1 -1
package/lib/drachtio-agent.js
CHANGED
|
@@ -301,7 +301,14 @@ class DrachtioAgent extends Emitter {
|
|
|
301
301
|
transactionId: transactionId
|
|
302
302
|
};
|
|
303
303
|
|
|
304
|
-
|
|
304
|
+
let sipMsg;
|
|
305
|
+
try {
|
|
306
|
+
sipMsg = new SipMessage(msg);
|
|
307
|
+
} catch(err) {
|
|
308
|
+
console.error(err, `unable to parse echoed sent request: ${msg}`);
|
|
309
|
+
return params.callback(err);
|
|
310
|
+
}
|
|
311
|
+
const req = new Request(sipMsg, meta);
|
|
305
312
|
req.agent = this;
|
|
306
313
|
req.socket = obj.socket;
|
|
307
314
|
if (params.options.auth) {
|
|
@@ -356,7 +363,14 @@ class DrachtioAgent extends Emitter {
|
|
|
356
363
|
obj.pendingRequests.set(msgId, (token, msg, meta) => {
|
|
357
364
|
obj.pendingRequests.delete(msgId);
|
|
358
365
|
if ('OK' !== token[0]) { if (callback) return callback(token[1]); return; }
|
|
359
|
-
|
|
366
|
+
let responseMsg;
|
|
367
|
+
try {
|
|
368
|
+
responseMsg = new SipMessage(msg);
|
|
369
|
+
} catch(err) {
|
|
370
|
+
console.error(err, `unable to parse echoed sent response: ${msg}`);
|
|
371
|
+
if (callback) callback(err);
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
360
374
|
res.meta = meta;
|
|
361
375
|
if (callback) {
|
|
362
376
|
callback(null, responseMsg);
|
|
@@ -401,7 +415,14 @@ class DrachtioAgent extends Emitter {
|
|
|
401
415
|
if ('OK' !== token[0]) {
|
|
402
416
|
return callback(token[1]);
|
|
403
417
|
}
|
|
404
|
-
|
|
418
|
+
let sipMsg;
|
|
419
|
+
try {
|
|
420
|
+
sipMsg = new SipMessage(msg);
|
|
421
|
+
} catch(err) {
|
|
422
|
+
console.error(err, `unable to parse echoed sent ACK: ${msg}`);
|
|
423
|
+
return callback(err);
|
|
424
|
+
}
|
|
425
|
+
callback(null, sipMsg);
|
|
405
426
|
});
|
|
406
427
|
}
|
|
407
428
|
}
|
|
@@ -808,7 +829,13 @@ class DrachtioAgent extends Emitter {
|
|
|
808
829
|
const msgSource = token[2];
|
|
809
830
|
const msgTime = token[3];
|
|
810
831
|
rawMsg = msg.slice(pos + 2);
|
|
811
|
-
|
|
832
|
+
let cdrSipMsg;
|
|
833
|
+
try {
|
|
834
|
+
cdrSipMsg = new SipMessage(rawMsg);
|
|
835
|
+
} catch(err) {
|
|
836
|
+
console.error(err, `unable to parse CDR sip message: ${rawMsg}`);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
812
839
|
const args = [msgSource, msgTime];
|
|
813
840
|
if (cdrEvent !== 'attempt') { args.push(token[4]); }
|
|
814
841
|
args.push(cdrSipMsg);
|