genesys-cloud-streaming-client 18.0.0 → 18.0.1-master-to-develop.3

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.
@@ -579,7 +579,7 @@ class Client extends events_1.default {
579
579
  return Client.version;
580
580
  }
581
581
  static get version() {
582
- return '18.0.0';
582
+ return '18.0.1';
583
583
  }
584
584
  }
585
585
  exports.Client = Client;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EventEmitter } from 'events';
3
3
  import { IQ } from 'stanza/protocol';
4
+ import { LRUCache } from 'lru-cache';
4
5
  import { SessionManager } from 'stanza/jingle';
5
6
  import { SessionOpts } from 'stanza/jingle/Session';
6
7
  import { Client } from './client';
@@ -19,7 +20,8 @@ export interface InitRtcSessionOptions {
19
20
  }
20
21
  export declare class WebrtcExtension extends EventEmitter implements StreamingClientExtension {
21
22
  client: Client;
22
- ignoredSessions: any;
23
+ ignoredSessions: LRUCache<string, boolean, unknown>;
24
+ private earlyIceCandidates;
23
25
  logger: any;
24
26
  pendingSessions: {
25
27
  [sessionId: string]: IPendingSession;
@@ -47,6 +49,7 @@ export declare class WebrtcExtension extends EventEmitter implements StreamingCl
47
49
  configureNewStanzaInstance(stanzaInstance: NamedAgent): Promise<void>;
48
50
  private configureStanzaIceServers;
49
51
  private handleGenesysOffer;
52
+ private applyEarlyIceCandidates;
50
53
  private handleGenesysRenegotiate;
51
54
  private handleGenesysIceCandidate;
52
55
  private handleGenesysTerminate;
@@ -4,7 +4,7 @@ exports.WebrtcExtension = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const events_1 = require("events");
6
6
  const JID_1 = require("stanza/JID");
7
- const lru_cache_1 = tslib_1.__importDefault(require("lru-cache"));
7
+ const lru_cache_1 = require("lru-cache");
8
8
  const Constants_1 = require("stanza/Constants");
9
9
  const uuid_1 = require("uuid");
10
10
  const lodash_throttle_1 = tslib_1.__importDefault(require("lodash.throttle"));
@@ -43,7 +43,11 @@ const ICE_SERVER_REFRESH_PERIOD = 1000 * 60 * 60 * 6; // 6 hours
43
43
  class WebrtcExtension extends events_1.EventEmitter {
44
44
  constructor(client, clientOptions) {
45
45
  super();
46
- this.ignoredSessions = new lru_cache_1.default({ max: 10, maxAge: 10 * 60 * 60 * 6 });
46
+ // sessionId maps to boolean where `true` means the sessionId is ignored
47
+ this.ignoredSessions = new lru_cache_1.LRUCache({ max: 10, ttl: 10 * 60 * 60 * 6 });
48
+ // sessionId maps to a list of sdp ice candidates
49
+ // hold onto early candidates for 1 minute
50
+ this.earlyIceCandidates = new lru_cache_1.LRUCache({ max: 10, ttl: 1000 * 60, ttlAutopurge: true });
47
51
  this.pendingSessions = {};
48
52
  this.statsArr = [];
49
53
  this.throttleSendStatsInterval = 25000;
@@ -197,9 +201,19 @@ class WebrtcExtension extends events_1.EventEmitter {
197
201
  this.webrtcSessions = this.webrtcSessions.filter(s => s.id !== session.id);
198
202
  });
199
203
  this.webrtcSessions.push(session);
200
- this.logger.info('emitting sdp media-session (offer)');
204
+ this.logger.info('emitting sdp media-session (offer');
205
+ this.applyEarlyIceCandidates(session);
201
206
  return this.emit(events.INCOMING_RTCSESSION, session);
202
207
  }
208
+ applyEarlyIceCandidates(session) {
209
+ const earlyCandidates = this.earlyIceCandidates.get(session.id);
210
+ if (earlyCandidates) {
211
+ this.earlyIceCandidates.delete(session.id);
212
+ for (const candidate of earlyCandidates) {
213
+ void session.addRemoteIceCandidate(candidate);
214
+ }
215
+ }
216
+ }
203
217
  async handleGenesysRenegotiate(existingSession, newSdp) {
204
218
  await existingSession.peerConnection.setRemoteDescription({ sdp: newSdp, type: 'offer' });
205
219
  await existingSession.accept();
@@ -207,8 +221,19 @@ class WebrtcExtension extends events_1.EventEmitter {
207
221
  async handleGenesysIceCandidate(iq) {
208
222
  const message = iq.genesysWebrtc;
209
223
  const params = message.params;
210
- const session = this.getSessionById(params.sessionId);
211
- await session.addRemoteIceCandidate(params.sdp);
224
+ const session = this.getSessionById(params.sessionId, true);
225
+ if (session) {
226
+ await session.addRemoteIceCandidate(params.sdp);
227
+ }
228
+ else {
229
+ const earlyCandidates = this.earlyIceCandidates.get(params.sessionId);
230
+ if (earlyCandidates) {
231
+ this.earlyIceCandidates.set(params.sessionId, [...earlyCandidates, params.sdp]);
232
+ }
233
+ else {
234
+ this.earlyIceCandidates.set(params.sessionId, [params.sdp]);
235
+ }
236
+ }
212
237
  }
213
238
  async handleGenesysTerminate(iq) {
214
239
  const message = iq.genesysWebrtc;
@@ -216,9 +241,9 @@ class WebrtcExtension extends events_1.EventEmitter {
216
241
  const session = this.getSessionById(params.sessionId);
217
242
  session.onSessionTerminate(params.reason);
218
243
  }
219
- getSessionById(id) {
244
+ getSessionById(id, nullIfNotFound = false) {
220
245
  const session = this.getAllSessions().find(session => session.id === id);
221
- if (!session) {
246
+ if (!session && !nullIfNotFound) {
222
247
  const error = new Error('Failed to find session by id');
223
248
  this.logger.error(error, { sessionId: id });
224
249
  throw error;
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "developercenter-cdn/streaming-client",
3
- "version": "18.0.0",
3
+ "version": "master-to-develop",
4
4
  "ecosystem": "pc",
5
5
  "team": "Client Streaming and Signaling",
6
6
  "indexFiles": [
7
7
  {
8
- "file": "v18.0.0/streaming-client.browser.ie.js"
8
+ "file": "v18.0.1/streaming-client.browser.ie.js"
9
9
  },
10
10
  {
11
- "file": "v18.0.0/streaming-client.browser.js"
11
+ "file": "v18.0.1/streaming-client.browser.js"
12
12
  },
13
13
  {
14
14
  "file": "v18/streaming-client.browser.ie.js"
@@ -17,6 +17,6 @@
17
17
  "file": "v18/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "104",
21
- "buildDate": "2024-11-19T03:54:39.596895772Z"
20
+ "build": "3",
21
+ "buildDate": "2024-12-05T19:50:03.399273514Z"
22
22
  }
package/dist/es/client.js CHANGED
@@ -591,6 +591,6 @@ export class Client extends EventEmitter {
591
591
  return Client.version;
592
592
  }
593
593
  static get version() {
594
- return '18.0.0';
594
+ return '18.0.1';
595
595
  }
596
596
  }