@anganyai/voice-sdk 0.0.6 → 0.0.7
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/dist/index.cjs +56 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +56 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16423,6 +16423,15 @@ var SipManager = class extends EventEmitter {
|
|
|
16423
16423
|
}
|
|
16424
16424
|
const inviter = new Inviter(this.userAgent, uri, inviterOptions);
|
|
16425
16425
|
this.currentSession = inviter;
|
|
16426
|
+
let rejectionReason;
|
|
16427
|
+
inviter.delegate = {
|
|
16428
|
+
onReject: (response) => {
|
|
16429
|
+
const statusCode = response.message.statusCode;
|
|
16430
|
+
const reasonPhrase = response.message.reasonPhrase;
|
|
16431
|
+
this.logger.warn("Call rejected", { statusCode, reasonPhrase });
|
|
16432
|
+
rejectionReason = { code: statusCode, reason: this.mapSipErrorToMessage(statusCode, reasonPhrase) };
|
|
16433
|
+
}
|
|
16434
|
+
};
|
|
16426
16435
|
inviter.stateChange.addListener((state) => {
|
|
16427
16436
|
this.logger.debug("Call state changed", { state });
|
|
16428
16437
|
switch (state) {
|
|
@@ -16436,6 +16445,9 @@ var SipManager = class extends EventEmitter {
|
|
|
16436
16445
|
break;
|
|
16437
16446
|
case SessionState2.Terminated:
|
|
16438
16447
|
this.setState("registered");
|
|
16448
|
+
if (rejectionReason) {
|
|
16449
|
+
this.emit("error", new Error(rejectionReason.reason));
|
|
16450
|
+
}
|
|
16439
16451
|
this.emit("callEnded");
|
|
16440
16452
|
this.cleanupAudioResources();
|
|
16441
16453
|
delete this.currentSession;
|
|
@@ -16901,6 +16913,50 @@ var SipManager = class extends EventEmitter {
|
|
|
16901
16913
|
}
|
|
16902
16914
|
}, delay);
|
|
16903
16915
|
}
|
|
16916
|
+
/**
|
|
16917
|
+
* Map SIP error codes to user-friendly messages
|
|
16918
|
+
*/
|
|
16919
|
+
mapSipErrorToMessage(statusCode, reasonPhrase) {
|
|
16920
|
+
const errorMessages = {
|
|
16921
|
+
// 4xx Client Errors
|
|
16922
|
+
400: "Invalid request",
|
|
16923
|
+
401: "Authentication required",
|
|
16924
|
+
403: "Access denied",
|
|
16925
|
+
404: "Agent not found",
|
|
16926
|
+
408: "Request timeout",
|
|
16927
|
+
480: "Agent unavailable",
|
|
16928
|
+
486: "Agent is busy",
|
|
16929
|
+
487: "Call cancelled",
|
|
16930
|
+
488: "Not acceptable",
|
|
16931
|
+
// 5xx Server Errors
|
|
16932
|
+
500: "Server error",
|
|
16933
|
+
502: "Bad gateway",
|
|
16934
|
+
503: "Service unavailable",
|
|
16935
|
+
504: "Gateway timeout",
|
|
16936
|
+
// 6xx Global Failures
|
|
16937
|
+
600: "Agent is busy",
|
|
16938
|
+
603: "Agent declined the call",
|
|
16939
|
+
604: "Agent does not exist",
|
|
16940
|
+
606: "Not acceptable"
|
|
16941
|
+
};
|
|
16942
|
+
const message = errorMessages[statusCode];
|
|
16943
|
+
if (message) {
|
|
16944
|
+
return message;
|
|
16945
|
+
}
|
|
16946
|
+
if (reasonPhrase) {
|
|
16947
|
+
return reasonPhrase;
|
|
16948
|
+
}
|
|
16949
|
+
if (statusCode >= 400 && statusCode < 500) {
|
|
16950
|
+
return "Call failed";
|
|
16951
|
+
}
|
|
16952
|
+
if (statusCode >= 500 && statusCode < 600) {
|
|
16953
|
+
return "Server error";
|
|
16954
|
+
}
|
|
16955
|
+
if (statusCode >= 600) {
|
|
16956
|
+
return "Agent unavailable";
|
|
16957
|
+
}
|
|
16958
|
+
return "Unknown error";
|
|
16959
|
+
}
|
|
16904
16960
|
};
|
|
16905
16961
|
|
|
16906
16962
|
// src/services/TranscriptionService.ts
|