@vonage/client-sdk 2.3.1-alpha.1 → 2.4.0-alpha.0
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/api_docs/ts/assets/highlight.css +4 -4
- package/api_docs/ts/assets/search.js +1 -1
- package/api_docs/ts/classes/VonageClient.html +15 -10
- package/api_docs/ts/index.html +9 -5
- package/api_docs/ts/interfaces/VonageEvent.html +3 -2
- package/api_docs/ts/types/ClientConfigObject.html +1 -1
- package/dist/client/VonageClient.d.ts +29 -8
- package/dist/client/index.cjs +73 -30
- package/dist/client/index.mjs +73 -30
- package/dist/utils/ClientConfig.d.ts +1 -1
- package/dist/vonageClientSDK.js +73 -30
- package/dist/vonageClientSDK.min.js +1 -1
- package/dist/vonageClientSDK.min.mjs +1 -1
- package/dist/vonageClientSDK.mjs +73 -30
- package/package.json +1 -1
package/dist/client/index.cjs
CHANGED
|
@@ -34506,6 +34506,13 @@ function requireClientsdkClientcore () {
|
|
|
34506
34506
|
function onConversationEvent(event) {
|
|
34507
34507
|
}
|
|
34508
34508
|
initMetadataForInterface(ConversationEventListener, 'ConversationEventListener');
|
|
34509
|
+
function onRTCHangup(conversationId, legId, hangup) {
|
|
34510
|
+
}
|
|
34511
|
+
function onRTCTransfer(conversationId, legId) {
|
|
34512
|
+
}
|
|
34513
|
+
function onLegStatusUpdate(conversationId, legId, fromUserId, status) {
|
|
34514
|
+
}
|
|
34515
|
+
initMetadataForInterface(RTCEventListener, 'RTCEventListener');
|
|
34509
34516
|
function onAudioSay() {
|
|
34510
34517
|
}
|
|
34511
34518
|
function onAudioMuteUpdate(conversationId, legId, isMuted) {
|
|
@@ -34515,14 +34522,7 @@ function requireClientsdkClientcore () {
|
|
|
34515
34522
|
function onAudioDTMFUpdate(conversationId, legId, digits) {
|
|
34516
34523
|
}
|
|
34517
34524
|
initMetadataForInterface(AudioEventListener, 'AudioEventListener');
|
|
34518
|
-
|
|
34519
|
-
}
|
|
34520
|
-
function onRTCTransfer(conversationId, legId) {
|
|
34521
|
-
}
|
|
34522
|
-
function onLegStatusUpdate(conversationId, legId, fromUserId, status) {
|
|
34523
|
-
}
|
|
34524
|
-
initMetadataForInterface(RTCEventListener, 'RTCEventListener');
|
|
34525
|
-
initMetadataForClass(ChatAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, AudioEventListener, RTCEventListener]);
|
|
34525
|
+
initMetadataForClass(ChatAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, RTCEventListener, AudioEventListener]);
|
|
34526
34526
|
initMetadataForClass(ChatAPIImpl, 'ChatAPIImpl', VOID, VOID, [ChatAPI]);
|
|
34527
34527
|
initMetadataForClass(LoggingLevel, 'LoggingLevel', VOID, Enum);
|
|
34528
34528
|
initMetadataForObject(DefaultConfig, 'DefaultConfig');
|
|
@@ -34678,7 +34678,7 @@ function requireClientsdkClientcore () {
|
|
|
34678
34678
|
initMetadataForClass(HangupReason, 'HangupReason', VOID, Enum);
|
|
34679
34679
|
initMetadataForClass(LegStatus, 'LegStatus', VOID, Enum);
|
|
34680
34680
|
initMetadataForClass(CallDisconnectReason, 'CallDisconnectReason', VOID, Enum);
|
|
34681
|
-
initMetadataForClass(VoiceAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener,
|
|
34681
|
+
initMetadataForClass(VoiceAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, RTCEventListener, AudioEventListener]);
|
|
34682
34682
|
initMetadataForClass(VoiceAPIImpl, 'VoiceAPIImpl');
|
|
34683
34683
|
initMetadataForInterface(CallEvent, 'CallEvent');
|
|
34684
34684
|
initMetadataForClass(SetupOutboundCall, 'SetupOutboundCall', VOID, VOID, [CallEvent]);
|
|
@@ -34897,7 +34897,7 @@ function requireClientsdkClientcore () {
|
|
|
34897
34897
|
initMetadataForClass(runAfterDelay$1);
|
|
34898
34898
|
//endregion
|
|
34899
34899
|
function BuildKonfig() {
|
|
34900
|
-
this.t1e_1 = '2.
|
|
34900
|
+
this.t1e_1 = '2.4.0-alpha.0';
|
|
34901
34901
|
}
|
|
34902
34902
|
var BuildKonfig_instance;
|
|
34903
34903
|
function BuildKonfig_getInstance() {
|
|
@@ -89557,15 +89557,23 @@ class HttpClient {
|
|
|
89557
89557
|
}
|
|
89558
89558
|
}
|
|
89559
89559
|
|
|
89560
|
+
const ICE_GATHERING_TIMEOUT_MS = 10000;
|
|
89560
89561
|
const waitFirstICEGatheringComplete = (peerConnection) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89561
89562
|
let offer_sent = false;
|
|
89562
|
-
return new Promise((resolve) => {
|
|
89563
|
-
|
|
89563
|
+
return new Promise((resolve, reject) => {
|
|
89564
|
+
const handler = (event) => {
|
|
89564
89565
|
if (event.candidate && !offer_sent) {
|
|
89565
89566
|
offer_sent = true;
|
|
89567
|
+
clearTimeout(timeoutId);
|
|
89568
|
+
peerConnection.removeEventListener('icecandidate', handler);
|
|
89566
89569
|
resolve();
|
|
89567
89570
|
}
|
|
89568
89571
|
};
|
|
89572
|
+
peerConnection.addEventListener('icecandidate', handler);
|
|
89573
|
+
const timeoutId = setTimeout(() => {
|
|
89574
|
+
peerConnection.removeEventListener('icecandidate', handler);
|
|
89575
|
+
reject(new Error(`ICE gathering timed out after ${ICE_GATHERING_TIMEOUT_MS}ms`));
|
|
89576
|
+
}, ICE_GATHERING_TIMEOUT_MS);
|
|
89569
89577
|
});
|
|
89570
89578
|
});
|
|
89571
89579
|
function createDummyCandidateSDP(pc) {
|
|
@@ -89820,8 +89828,25 @@ const TrackType = {
|
|
|
89820
89828
|
class MediaClient {
|
|
89821
89829
|
constructor() {
|
|
89822
89830
|
this.pcs = new Map();
|
|
89831
|
+
this.pcListeners = new WeakMap();
|
|
89823
89832
|
this.audio = undefined;
|
|
89824
89833
|
}
|
|
89834
|
+
setPeerConnectionCreatedCallback(callback) {
|
|
89835
|
+
this.peerConnectionCreatedCallback = callback;
|
|
89836
|
+
}
|
|
89837
|
+
addPCListener(pc, type, listener) {
|
|
89838
|
+
var _a;
|
|
89839
|
+
pc.addEventListener(type, listener);
|
|
89840
|
+
const list = (_a = this.pcListeners.get(pc)) !== null && _a !== void 0 ? _a : [];
|
|
89841
|
+
list.push({ type, listener });
|
|
89842
|
+
this.pcListeners.set(pc, list);
|
|
89843
|
+
}
|
|
89844
|
+
removeAllPCListeners(pc) {
|
|
89845
|
+
var _a;
|
|
89846
|
+
(_a = this.pcListeners
|
|
89847
|
+
.get(pc)) === null || _a === void 0 ? void 0 : _a.forEach(({ type, listener }) => pc.removeEventListener(type, listener));
|
|
89848
|
+
this.pcListeners.delete(pc);
|
|
89849
|
+
}
|
|
89825
89850
|
enableRtcStatsCollection(id, interval, closure) {
|
|
89826
89851
|
const pc = this.pcs.get(id);
|
|
89827
89852
|
if (!pc) {
|
|
@@ -89846,11 +89871,11 @@ class MediaClient {
|
|
|
89846
89871
|
enableMediaInbound(rtcId, offerSDP, closure) {
|
|
89847
89872
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89848
89873
|
try {
|
|
89849
|
-
const pc = yield this.getNewPC();
|
|
89850
|
-
pc
|
|
89874
|
+
const pc = yield this.getNewPC(rtcId);
|
|
89875
|
+
this.addPCListener(pc, 'connectionstatechange', (() => {
|
|
89851
89876
|
var _a;
|
|
89852
89877
|
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.onConnectionChange(rtcId, pc.connectionState);
|
|
89853
|
-
};
|
|
89878
|
+
}));
|
|
89854
89879
|
this.pcs.set(rtcId, pc);
|
|
89855
89880
|
const sdp = yield createAnswer(pc, offerSDP);
|
|
89856
89881
|
closure(null, sdp);
|
|
@@ -89863,8 +89888,9 @@ class MediaClient {
|
|
|
89863
89888
|
}
|
|
89864
89889
|
enableMediaOutbound(closure) {
|
|
89865
89890
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89891
|
+
let pc;
|
|
89866
89892
|
try {
|
|
89867
|
-
|
|
89893
|
+
pc = yield this.getNewPC(null);
|
|
89868
89894
|
const sdp = yield createOffer(pc);
|
|
89869
89895
|
closure(null, sdp, (legId) => {
|
|
89870
89896
|
if (!legId) {
|
|
@@ -89873,13 +89899,15 @@ class MediaClient {
|
|
|
89873
89899
|
return;
|
|
89874
89900
|
}
|
|
89875
89901
|
this.pcs.set(legId, pc);
|
|
89876
|
-
pc
|
|
89902
|
+
this.addPCListener(pc, 'connectionstatechange', (() => {
|
|
89877
89903
|
var _a;
|
|
89878
89904
|
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.onConnectionChange(legId, pc.connectionState);
|
|
89879
|
-
};
|
|
89905
|
+
}));
|
|
89880
89906
|
});
|
|
89881
89907
|
}
|
|
89882
89908
|
catch (err) {
|
|
89909
|
+
if (pc)
|
|
89910
|
+
this.closePeerConnection(pc);
|
|
89883
89911
|
const message = err instanceof Error ? err.message : null;
|
|
89884
89912
|
closure(new clientsdkClientcore_jsExports.vonage.CreateOfferErrorJS(message), null, () => {
|
|
89885
89913
|
throw new Error('Callback not implemented, and should never get called');
|
|
@@ -89887,10 +89915,11 @@ class MediaClient {
|
|
|
89887
89915
|
}
|
|
89888
89916
|
});
|
|
89889
89917
|
}
|
|
89890
|
-
getNewPC() {
|
|
89918
|
+
getNewPC(callId) {
|
|
89919
|
+
var _a;
|
|
89891
89920
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89892
89921
|
const pc = yield createRtcAudioConnection();
|
|
89893
|
-
pc
|
|
89922
|
+
this.addPCListener(pc, 'track', ((evt) => {
|
|
89894
89923
|
const stream = evt.streams[0];
|
|
89895
89924
|
if (stream) {
|
|
89896
89925
|
const audio = new Audio();
|
|
@@ -89898,7 +89927,8 @@ class MediaClient {
|
|
|
89898
89927
|
audio.autoplay = true;
|
|
89899
89928
|
this.audio = audio;
|
|
89900
89929
|
}
|
|
89901
|
-
};
|
|
89930
|
+
}));
|
|
89931
|
+
(_a = this.peerConnectionCreatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, callId, pc);
|
|
89902
89932
|
return pc;
|
|
89903
89933
|
});
|
|
89904
89934
|
}
|
|
@@ -89986,6 +90016,7 @@ class MediaClient {
|
|
|
89986
90016
|
// Private Methods
|
|
89987
90017
|
closePeerConnection(pc) {
|
|
89988
90018
|
var _a;
|
|
90019
|
+
this.removeAllPCListeners(pc);
|
|
89989
90020
|
pc.close();
|
|
89990
90021
|
pc.getSenders().forEach((sender) => {
|
|
89991
90022
|
var _a;
|
|
@@ -90436,7 +90467,8 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90436
90467
|
super.emitter = value;
|
|
90437
90468
|
}
|
|
90438
90469
|
constructor(config = new ClientInitConfig()) {
|
|
90439
|
-
|
|
90470
|
+
const mediaClient = new MediaClient();
|
|
90471
|
+
super(convertInitConfig(config), new HttpClient(), new SocketClient(), mediaClient);
|
|
90440
90472
|
/**
|
|
90441
90473
|
* Proxy object to allow for registering callbacks via `on()`
|
|
90442
90474
|
* @internal
|
|
@@ -90466,13 +90498,17 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90466
90498
|
};
|
|
90467
90499
|
}
|
|
90468
90500
|
});
|
|
90501
|
+
mediaClient.setPeerConnectionCreatedCallback((callId, pc) => {
|
|
90502
|
+
var _a, _b;
|
|
90503
|
+
(_b = (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.peerConnectionCreated) === null || _b === void 0 ? void 0 : _b.call(_a, callId, pc);
|
|
90504
|
+
});
|
|
90469
90505
|
this.setConfig(config);
|
|
90470
90506
|
}
|
|
90471
90507
|
/**
|
|
90472
90508
|
* Set a configuration for the client SDK
|
|
90473
90509
|
*
|
|
90474
90510
|
* @example
|
|
90475
|
-
* [[include:
|
|
90511
|
+
* [[include: snippet_Config.txt]]
|
|
90476
90512
|
*
|
|
90477
90513
|
* @param config - A configuration object
|
|
90478
90514
|
* @returns void
|
|
@@ -90548,17 +90584,24 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90548
90584
|
callbacks.clear();
|
|
90549
90585
|
}
|
|
90550
90586
|
/**
|
|
90551
|
-
* Create
|
|
90552
|
-
*
|
|
90553
|
-
*
|
|
90554
|
-
*
|
|
90587
|
+
* Create (or reconnect to) a session.
|
|
90588
|
+
*
|
|
90589
|
+
* When `sessionId` is omitted or `null`, a completely new session is created.
|
|
90590
|
+
*
|
|
90591
|
+
* When `sessionId` is set to the value returned by a **previous** `createSession` call, the
|
|
90592
|
+
* Conversation Service will replay any pending events into the new session. In particular, an
|
|
90593
|
+
* unanswered inbound call invite that arrived before a page refresh will be re-delivered so that
|
|
90594
|
+
* `onCallInvite` fires automatically — no extra API call is needed.
|
|
90595
|
+
*
|
|
90596
|
+
* **Important:** The Conversation Service retains pending events for approximately 30 seconds.
|
|
90597
|
+
* Persist the session ID (e.g. in `sessionStorage`) and pass it back within that window.
|
|
90555
90598
|
*
|
|
90556
90599
|
* @example
|
|
90557
90600
|
* [[include: snippet_SessionCreate.txt]]
|
|
90558
90601
|
*
|
|
90559
|
-
* @param token
|
|
90560
|
-
* @param sessionId -
|
|
90561
|
-
* @returns
|
|
90602
|
+
* @param token - JWT token of the user.
|
|
90603
|
+
* @param sessionId - Optional previous session ID. Omit or pass `null` for a fresh session.
|
|
90604
|
+
* @returns The `sessionId` of the newly established session.
|
|
90562
90605
|
*/
|
|
90563
90606
|
createSession(token, sessionId) {
|
|
90564
90607
|
const _super = Object.create(null, {
|
package/dist/client/index.mjs
CHANGED
|
@@ -34482,6 +34482,13 @@ function requireClientsdkClientcore () {
|
|
|
34482
34482
|
function onConversationEvent(event) {
|
|
34483
34483
|
}
|
|
34484
34484
|
initMetadataForInterface(ConversationEventListener, 'ConversationEventListener');
|
|
34485
|
+
function onRTCHangup(conversationId, legId, hangup) {
|
|
34486
|
+
}
|
|
34487
|
+
function onRTCTransfer(conversationId, legId) {
|
|
34488
|
+
}
|
|
34489
|
+
function onLegStatusUpdate(conversationId, legId, fromUserId, status) {
|
|
34490
|
+
}
|
|
34491
|
+
initMetadataForInterface(RTCEventListener, 'RTCEventListener');
|
|
34485
34492
|
function onAudioSay() {
|
|
34486
34493
|
}
|
|
34487
34494
|
function onAudioMuteUpdate(conversationId, legId, isMuted) {
|
|
@@ -34491,14 +34498,7 @@ function requireClientsdkClientcore () {
|
|
|
34491
34498
|
function onAudioDTMFUpdate(conversationId, legId, digits) {
|
|
34492
34499
|
}
|
|
34493
34500
|
initMetadataForInterface(AudioEventListener, 'AudioEventListener');
|
|
34494
|
-
|
|
34495
|
-
}
|
|
34496
|
-
function onRTCTransfer(conversationId, legId) {
|
|
34497
|
-
}
|
|
34498
|
-
function onLegStatusUpdate(conversationId, legId, fromUserId, status) {
|
|
34499
|
-
}
|
|
34500
|
-
initMetadataForInterface(RTCEventListener, 'RTCEventListener');
|
|
34501
|
-
initMetadataForClass(ChatAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, AudioEventListener, RTCEventListener]);
|
|
34501
|
+
initMetadataForClass(ChatAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, RTCEventListener, AudioEventListener]);
|
|
34502
34502
|
initMetadataForClass(ChatAPIImpl, 'ChatAPIImpl', VOID, VOID, [ChatAPI]);
|
|
34503
34503
|
initMetadataForClass(LoggingLevel, 'LoggingLevel', VOID, Enum);
|
|
34504
34504
|
initMetadataForObject(DefaultConfig, 'DefaultConfig');
|
|
@@ -34654,7 +34654,7 @@ function requireClientsdkClientcore () {
|
|
|
34654
34654
|
initMetadataForClass(HangupReason, 'HangupReason', VOID, Enum);
|
|
34655
34655
|
initMetadataForClass(LegStatus, 'LegStatus', VOID, Enum);
|
|
34656
34656
|
initMetadataForClass(CallDisconnectReason, 'CallDisconnectReason', VOID, Enum);
|
|
34657
|
-
initMetadataForClass(VoiceAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener,
|
|
34657
|
+
initMetadataForClass(VoiceAPIImpl$1, VOID, VOID, VOID, [ConversationEventListener, RTCEventListener, AudioEventListener]);
|
|
34658
34658
|
initMetadataForClass(VoiceAPIImpl, 'VoiceAPIImpl');
|
|
34659
34659
|
initMetadataForInterface(CallEvent, 'CallEvent');
|
|
34660
34660
|
initMetadataForClass(SetupOutboundCall, 'SetupOutboundCall', VOID, VOID, [CallEvent]);
|
|
@@ -34873,7 +34873,7 @@ function requireClientsdkClientcore () {
|
|
|
34873
34873
|
initMetadataForClass(runAfterDelay$1);
|
|
34874
34874
|
//endregion
|
|
34875
34875
|
function BuildKonfig() {
|
|
34876
|
-
this.t1e_1 = '2.
|
|
34876
|
+
this.t1e_1 = '2.4.0-alpha.0';
|
|
34877
34877
|
}
|
|
34878
34878
|
var BuildKonfig_instance;
|
|
34879
34879
|
function BuildKonfig_getInstance() {
|
|
@@ -89533,15 +89533,23 @@ class HttpClient {
|
|
|
89533
89533
|
}
|
|
89534
89534
|
}
|
|
89535
89535
|
|
|
89536
|
+
const ICE_GATHERING_TIMEOUT_MS = 10000;
|
|
89536
89537
|
const waitFirstICEGatheringComplete = (peerConnection) => __awaiter(void 0, void 0, void 0, function* () {
|
|
89537
89538
|
let offer_sent = false;
|
|
89538
|
-
return new Promise((resolve) => {
|
|
89539
|
-
|
|
89539
|
+
return new Promise((resolve, reject) => {
|
|
89540
|
+
const handler = (event) => {
|
|
89540
89541
|
if (event.candidate && !offer_sent) {
|
|
89541
89542
|
offer_sent = true;
|
|
89543
|
+
clearTimeout(timeoutId);
|
|
89544
|
+
peerConnection.removeEventListener('icecandidate', handler);
|
|
89542
89545
|
resolve();
|
|
89543
89546
|
}
|
|
89544
89547
|
};
|
|
89548
|
+
peerConnection.addEventListener('icecandidate', handler);
|
|
89549
|
+
const timeoutId = setTimeout(() => {
|
|
89550
|
+
peerConnection.removeEventListener('icecandidate', handler);
|
|
89551
|
+
reject(new Error(`ICE gathering timed out after ${ICE_GATHERING_TIMEOUT_MS}ms`));
|
|
89552
|
+
}, ICE_GATHERING_TIMEOUT_MS);
|
|
89545
89553
|
});
|
|
89546
89554
|
});
|
|
89547
89555
|
function createDummyCandidateSDP(pc) {
|
|
@@ -89796,8 +89804,25 @@ const TrackType = {
|
|
|
89796
89804
|
class MediaClient {
|
|
89797
89805
|
constructor() {
|
|
89798
89806
|
this.pcs = new Map();
|
|
89807
|
+
this.pcListeners = new WeakMap();
|
|
89799
89808
|
this.audio = undefined;
|
|
89800
89809
|
}
|
|
89810
|
+
setPeerConnectionCreatedCallback(callback) {
|
|
89811
|
+
this.peerConnectionCreatedCallback = callback;
|
|
89812
|
+
}
|
|
89813
|
+
addPCListener(pc, type, listener) {
|
|
89814
|
+
var _a;
|
|
89815
|
+
pc.addEventListener(type, listener);
|
|
89816
|
+
const list = (_a = this.pcListeners.get(pc)) !== null && _a !== void 0 ? _a : [];
|
|
89817
|
+
list.push({ type, listener });
|
|
89818
|
+
this.pcListeners.set(pc, list);
|
|
89819
|
+
}
|
|
89820
|
+
removeAllPCListeners(pc) {
|
|
89821
|
+
var _a;
|
|
89822
|
+
(_a = this.pcListeners
|
|
89823
|
+
.get(pc)) === null || _a === void 0 ? void 0 : _a.forEach(({ type, listener }) => pc.removeEventListener(type, listener));
|
|
89824
|
+
this.pcListeners.delete(pc);
|
|
89825
|
+
}
|
|
89801
89826
|
enableRtcStatsCollection(id, interval, closure) {
|
|
89802
89827
|
const pc = this.pcs.get(id);
|
|
89803
89828
|
if (!pc) {
|
|
@@ -89822,11 +89847,11 @@ class MediaClient {
|
|
|
89822
89847
|
enableMediaInbound(rtcId, offerSDP, closure) {
|
|
89823
89848
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89824
89849
|
try {
|
|
89825
|
-
const pc = yield this.getNewPC();
|
|
89826
|
-
pc
|
|
89850
|
+
const pc = yield this.getNewPC(rtcId);
|
|
89851
|
+
this.addPCListener(pc, 'connectionstatechange', (() => {
|
|
89827
89852
|
var _a;
|
|
89828
89853
|
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.onConnectionChange(rtcId, pc.connectionState);
|
|
89829
|
-
};
|
|
89854
|
+
}));
|
|
89830
89855
|
this.pcs.set(rtcId, pc);
|
|
89831
89856
|
const sdp = yield createAnswer(pc, offerSDP);
|
|
89832
89857
|
closure(null, sdp);
|
|
@@ -89839,8 +89864,9 @@ class MediaClient {
|
|
|
89839
89864
|
}
|
|
89840
89865
|
enableMediaOutbound(closure) {
|
|
89841
89866
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89867
|
+
let pc;
|
|
89842
89868
|
try {
|
|
89843
|
-
|
|
89869
|
+
pc = yield this.getNewPC(null);
|
|
89844
89870
|
const sdp = yield createOffer(pc);
|
|
89845
89871
|
closure(null, sdp, (legId) => {
|
|
89846
89872
|
if (!legId) {
|
|
@@ -89849,13 +89875,15 @@ class MediaClient {
|
|
|
89849
89875
|
return;
|
|
89850
89876
|
}
|
|
89851
89877
|
this.pcs.set(legId, pc);
|
|
89852
|
-
pc
|
|
89878
|
+
this.addPCListener(pc, 'connectionstatechange', (() => {
|
|
89853
89879
|
var _a;
|
|
89854
89880
|
(_a = this.delegate) === null || _a === void 0 ? void 0 : _a.onConnectionChange(legId, pc.connectionState);
|
|
89855
|
-
};
|
|
89881
|
+
}));
|
|
89856
89882
|
});
|
|
89857
89883
|
}
|
|
89858
89884
|
catch (err) {
|
|
89885
|
+
if (pc)
|
|
89886
|
+
this.closePeerConnection(pc);
|
|
89859
89887
|
const message = err instanceof Error ? err.message : null;
|
|
89860
89888
|
closure(new clientsdkClientcore_jsExports.vonage.CreateOfferErrorJS(message), null, () => {
|
|
89861
89889
|
throw new Error('Callback not implemented, and should never get called');
|
|
@@ -89863,10 +89891,11 @@ class MediaClient {
|
|
|
89863
89891
|
}
|
|
89864
89892
|
});
|
|
89865
89893
|
}
|
|
89866
|
-
getNewPC() {
|
|
89894
|
+
getNewPC(callId) {
|
|
89895
|
+
var _a;
|
|
89867
89896
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89868
89897
|
const pc = yield createRtcAudioConnection();
|
|
89869
|
-
pc
|
|
89898
|
+
this.addPCListener(pc, 'track', ((evt) => {
|
|
89870
89899
|
const stream = evt.streams[0];
|
|
89871
89900
|
if (stream) {
|
|
89872
89901
|
const audio = new Audio();
|
|
@@ -89874,7 +89903,8 @@ class MediaClient {
|
|
|
89874
89903
|
audio.autoplay = true;
|
|
89875
89904
|
this.audio = audio;
|
|
89876
89905
|
}
|
|
89877
|
-
};
|
|
89906
|
+
}));
|
|
89907
|
+
(_a = this.peerConnectionCreatedCallback) === null || _a === void 0 ? void 0 : _a.call(this, callId, pc);
|
|
89878
89908
|
return pc;
|
|
89879
89909
|
});
|
|
89880
89910
|
}
|
|
@@ -89962,6 +89992,7 @@ class MediaClient {
|
|
|
89962
89992
|
// Private Methods
|
|
89963
89993
|
closePeerConnection(pc) {
|
|
89964
89994
|
var _a;
|
|
89995
|
+
this.removeAllPCListeners(pc);
|
|
89965
89996
|
pc.close();
|
|
89966
89997
|
pc.getSenders().forEach((sender) => {
|
|
89967
89998
|
var _a;
|
|
@@ -90412,7 +90443,8 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90412
90443
|
super.emitter = value;
|
|
90413
90444
|
}
|
|
90414
90445
|
constructor(config = new ClientInitConfig()) {
|
|
90415
|
-
|
|
90446
|
+
const mediaClient = new MediaClient();
|
|
90447
|
+
super(convertInitConfig(config), new HttpClient(), new SocketClient(), mediaClient);
|
|
90416
90448
|
/**
|
|
90417
90449
|
* Proxy object to allow for registering callbacks via `on()`
|
|
90418
90450
|
* @internal
|
|
@@ -90442,13 +90474,17 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90442
90474
|
};
|
|
90443
90475
|
}
|
|
90444
90476
|
});
|
|
90477
|
+
mediaClient.setPeerConnectionCreatedCallback((callId, pc) => {
|
|
90478
|
+
var _a, _b;
|
|
90479
|
+
(_b = (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.peerConnectionCreated) === null || _b === void 0 ? void 0 : _b.call(_a, callId, pc);
|
|
90480
|
+
});
|
|
90445
90481
|
this.setConfig(config);
|
|
90446
90482
|
}
|
|
90447
90483
|
/**
|
|
90448
90484
|
* Set a configuration for the client SDK
|
|
90449
90485
|
*
|
|
90450
90486
|
* @example
|
|
90451
|
-
* [[include:
|
|
90487
|
+
* [[include: snippet_Config.txt]]
|
|
90452
90488
|
*
|
|
90453
90489
|
* @param config - A configuration object
|
|
90454
90490
|
* @returns void
|
|
@@ -90524,17 +90560,24 @@ class VonageClient extends clientsdkClientcore_jsExports.vonage.CombinedClientJS
|
|
|
90524
90560
|
callbacks.clear();
|
|
90525
90561
|
}
|
|
90526
90562
|
/**
|
|
90527
|
-
* Create
|
|
90528
|
-
*
|
|
90529
|
-
*
|
|
90530
|
-
*
|
|
90563
|
+
* Create (or reconnect to) a session.
|
|
90564
|
+
*
|
|
90565
|
+
* When `sessionId` is omitted or `null`, a completely new session is created.
|
|
90566
|
+
*
|
|
90567
|
+
* When `sessionId` is set to the value returned by a **previous** `createSession` call, the
|
|
90568
|
+
* Conversation Service will replay any pending events into the new session. In particular, an
|
|
90569
|
+
* unanswered inbound call invite that arrived before a page refresh will be re-delivered so that
|
|
90570
|
+
* `onCallInvite` fires automatically — no extra API call is needed.
|
|
90571
|
+
*
|
|
90572
|
+
* **Important:** The Conversation Service retains pending events for approximately 30 seconds.
|
|
90573
|
+
* Persist the session ID (e.g. in `sessionStorage`) and pass it back within that window.
|
|
90531
90574
|
*
|
|
90532
90575
|
* @example
|
|
90533
90576
|
* [[include: snippet_SessionCreate.txt]]
|
|
90534
90577
|
*
|
|
90535
|
-
* @param token
|
|
90536
|
-
* @param sessionId -
|
|
90537
|
-
* @returns
|
|
90578
|
+
* @param token - JWT token of the user.
|
|
90579
|
+
* @param sessionId - Optional previous session ID. Omit or pass `null` for a fresh session.
|
|
90580
|
+
* @returns The `sessionId` of the newly established session.
|
|
90538
90581
|
*/
|
|
90539
90582
|
createSession(token, sessionId) {
|
|
90540
90583
|
const _super = Object.create(null, {
|
|
@@ -27,7 +27,7 @@ export declare const ConfigRegion: typeof vonage.CoreClientConfigRegionJS;
|
|
|
27
27
|
* @property emergencySecondaryRegion The secondary region URL for emergency services
|
|
28
28
|
*
|
|
29
29
|
* @example
|
|
30
|
-
* [[include:
|
|
30
|
+
* [[include:snippet_Config.txt]]
|
|
31
31
|
*/
|
|
32
32
|
export type ClientConfigObject = ConfigObjectJS | ({
|
|
33
33
|
region?: ConfigRegion;
|