genesys-cloud-streaming-client 14.2.1-PCM-1963.1 → 14.2.1-develop.21

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.
@@ -118,3 +118,8 @@ export interface IPendingSession {
118
118
  accepted?: boolean;
119
119
  sessionType: SessionTypes | SessionTypesAsStrings;
120
120
  }
121
+ export interface JsonRpcMessage {
122
+ jsonrpc: string;
123
+ method: string;
124
+ params?: any;
125
+ }
@@ -6,7 +6,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { EventEmitter } from 'events';
7
7
  import { JingleReason, JingleInfo, Jingle } from 'stanza/protocol';
8
8
  import { ActionCallback, SessionOpts } from 'stanza/jingle/Session';
9
- import { SessionTypes, SessionTypesAsStrings } from './interfaces';
9
+ import { JsonRpcMessage, SessionTypes, SessionTypesAsStrings } from './interfaces';
10
10
  export interface IGenesysCloudMediaSessionParams {
11
11
  options: SessionOpts;
12
12
  sessionType: SessionTypes | SessionTypesAsStrings;
@@ -30,6 +30,7 @@ export declare class GenesysCloudMediaSession extends MediaSession {
30
30
  ignoreHostCandidatesFromRemote: boolean;
31
31
  allowIPv6: boolean;
32
32
  allowTCP: boolean;
33
+ dataChannel?: RTCDataChannel;
33
34
  constructor(params: IGenesysCloudMediaSessionParams);
34
35
  private getLogDetails;
35
36
  onTransportInfo(changes: Jingle, cb: ActionCallback): Promise<void>;
@@ -42,6 +43,8 @@ export declare class GenesysCloudMediaSession extends MediaSession {
42
43
  onIceCandidate(e: RTCPeerConnectionIceEvent): void;
43
44
  onIceEndOfCandidates(): void;
44
45
  addTrack(track: MediaStreamTrack, stream?: MediaStream): Promise<void>;
46
+ _setupDataChannel(): void;
47
+ _handleDataChannelMessage(event: MessageEvent): void;
45
48
  }
46
49
  export interface SessionEvents {
47
50
  iceConnectionType: ({
@@ -58,6 +61,7 @@ export interface SessionEvents {
58
61
  terminated: JingleReason;
59
62
  stats: StatsEvent;
60
63
  endOfCandidates: void;
64
+ dataChannelMessage: JsonRpcMessage;
61
65
  }
62
66
  export interface GenesysCloudMediaSession extends StrictEventEmitter<EventEmitter, SessionEvents> {
63
67
  }
@@ -119,6 +119,7 @@ class GenesysCloudMediaSession extends jingle_1.MediaSession {
119
119
  infoType: Constants_1.JINGLE_INFO_ACTIVE
120
120
  }
121
121
  });
122
+ this._setupDataChannel();
122
123
  }
123
124
  else if (iceState === 'failed') {
124
125
  this._log('info', 'ICE connection failed', {
@@ -185,5 +186,37 @@ class GenesysCloudMediaSession extends jingle_1.MediaSession {
185
186
  return;
186
187
  });
187
188
  }
189
+ _setupDataChannel() {
190
+ var _a;
191
+ // this shouldn't happen, but we shouldn't set the datachannel up more than once
192
+ if (this.dataChannel) {
193
+ return;
194
+ }
195
+ // do nothing if a datachannel wasn't offered
196
+ if ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp.includes('webrtc-datachannel')) {
197
+ this._log('info', 'creating data channel');
198
+ this.dataChannel = this.pc.createDataChannel('videoConferenceControl');
199
+ this.dataChannel.addEventListener('open', () => {
200
+ this._log('info', 'data channel opened');
201
+ });
202
+ this.dataChannel.addEventListener('message', this._handleDataChannelMessage.bind(this));
203
+ this.dataChannel.addEventListener('close', () => {
204
+ this._log('info', 'closing data channel');
205
+ });
206
+ this.dataChannel.addEventListener('error', (error) => {
207
+ this._log('error', 'Error occurred with the data channel', error);
208
+ });
209
+ }
210
+ }
211
+ _handleDataChannelMessage(event) {
212
+ this._log('debug', 'data channel message received', event);
213
+ try {
214
+ const message = JSON.parse(event.data);
215
+ this.emit('dataChannelMessage', message);
216
+ }
217
+ catch (e) {
218
+ this._log('error', 'Failed to parse data channel message', { error: e });
219
+ }
220
+ }
188
221
  }
189
222
  exports.GenesysCloudMediaSession = GenesysCloudMediaSession;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "developercenter-cdn/streaming-client",
3
- "version": "PCM-1963",
3
+ "version": "14.2.1",
4
4
  "ecosystem": "pc",
5
5
  "team": "Genesys Client Media (WebRTC)",
6
6
  "indexFiles": [
@@ -17,6 +17,6 @@
17
17
  "file": "/v14/streaming-client.browser.js"
18
18
  }
19
19
  ],
20
- "build": "1",
21
- "buildDate": "2022-09-13T21:42:33.695073Z"
20
+ "build": "21",
21
+ "buildDate": "2022-09-14T21:29:01.144206Z"
22
22
  }
@@ -41472,6 +41472,7 @@ class GenesysCloudMediaSession extends jingle.MediaSession {
41472
41472
  infoType: Constants.JINGLE_INFO_ACTIVE
41473
41473
  }
41474
41474
  });
41475
+ this._setupDataChannel();
41475
41476
  }
41476
41477
  else if (iceState === 'failed') {
41477
41478
  this._log('info', 'ICE connection failed', {
@@ -41538,6 +41539,38 @@ class GenesysCloudMediaSession extends jingle.MediaSession {
41538
41539
  return;
41539
41540
  }));
41540
41541
  }
41542
+ _setupDataChannel() {
41543
+ var _a;
41544
+ // this shouldn't happen, but we shouldn't set the datachannel up more than once
41545
+ if (this.dataChannel) {
41546
+ return;
41547
+ }
41548
+ // do nothing if a datachannel wasn't offered
41549
+ if ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp.includes('webrtc-datachannel')) {
41550
+ this._log('info', 'creating data channel');
41551
+ this.dataChannel = this.pc.createDataChannel('videoConferenceControl');
41552
+ this.dataChannel.addEventListener('open', () => {
41553
+ this._log('info', 'data channel opened');
41554
+ });
41555
+ this.dataChannel.addEventListener('message', this._handleDataChannelMessage.bind(this));
41556
+ this.dataChannel.addEventListener('close', () => {
41557
+ this._log('info', 'closing data channel');
41558
+ });
41559
+ this.dataChannel.addEventListener('error', (error) => {
41560
+ this._log('error', 'Error occurred with the data channel', error);
41561
+ });
41562
+ }
41563
+ }
41564
+ _handleDataChannelMessage(event) {
41565
+ this._log('debug', 'data channel message received', event);
41566
+ try {
41567
+ const message = JSON.parse(event.data);
41568
+ this.emit('dataChannelMessage', message);
41569
+ }
41570
+ catch (e) {
41571
+ this._log('error', 'Failed to parse data channel message', { error: e });
41572
+ }
41573
+ }
41541
41574
  }
41542
41575
 
41543
41576
  function formatStatsEvent(event, extraDetails = {}) {
@@ -118,3 +118,8 @@ export interface IPendingSession {
118
118
  accepted?: boolean;
119
119
  sessionType: SessionTypes | SessionTypesAsStrings;
120
120
  }
121
+ export interface JsonRpcMessage {
122
+ jsonrpc: string;
123
+ method: string;
124
+ params?: any;
125
+ }
@@ -6,7 +6,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { EventEmitter } from 'events';
7
7
  import { JingleReason, JingleInfo, Jingle } from 'stanza/protocol';
8
8
  import { ActionCallback, SessionOpts } from 'stanza/jingle/Session';
9
- import { SessionTypes, SessionTypesAsStrings } from './interfaces';
9
+ import { JsonRpcMessage, SessionTypes, SessionTypesAsStrings } from './interfaces';
10
10
  export interface IGenesysCloudMediaSessionParams {
11
11
  options: SessionOpts;
12
12
  sessionType: SessionTypes | SessionTypesAsStrings;
@@ -30,6 +30,7 @@ export declare class GenesysCloudMediaSession extends MediaSession {
30
30
  ignoreHostCandidatesFromRemote: boolean;
31
31
  allowIPv6: boolean;
32
32
  allowTCP: boolean;
33
+ dataChannel?: RTCDataChannel;
33
34
  constructor(params: IGenesysCloudMediaSessionParams);
34
35
  private getLogDetails;
35
36
  onTransportInfo(changes: Jingle, cb: ActionCallback): Promise<void>;
@@ -42,6 +43,8 @@ export declare class GenesysCloudMediaSession extends MediaSession {
42
43
  onIceCandidate(e: RTCPeerConnectionIceEvent): void;
43
44
  onIceEndOfCandidates(): void;
44
45
  addTrack(track: MediaStreamTrack, stream?: MediaStream): Promise<void>;
46
+ _setupDataChannel(): void;
47
+ _handleDataChannelMessage(event: MessageEvent): void;
45
48
  }
46
49
  export interface SessionEvents {
47
50
  iceConnectionType: ({
@@ -58,6 +61,7 @@ export interface SessionEvents {
58
61
  terminated: JingleReason;
59
62
  stats: StatsEvent;
60
63
  endOfCandidates: void;
64
+ dataChannelMessage: JsonRpcMessage;
61
65
  }
62
66
  export interface GenesysCloudMediaSession extends StrictEventEmitter<EventEmitter, SessionEvents> {
63
67
  }
@@ -121,6 +121,7 @@ export class GenesysCloudMediaSession extends MediaSession {
121
121
  infoType: JINGLE_INFO_ACTIVE
122
122
  }
123
123
  });
124
+ this._setupDataChannel();
124
125
  }
125
126
  else if (iceState === 'failed') {
126
127
  this._log('info', 'ICE connection failed', {
@@ -187,4 +188,36 @@ export class GenesysCloudMediaSession extends MediaSession {
187
188
  return;
188
189
  }));
189
190
  }
191
+ _setupDataChannel() {
192
+ var _a;
193
+ // this shouldn't happen, but we shouldn't set the datachannel up more than once
194
+ if (this.dataChannel) {
195
+ return;
196
+ }
197
+ // do nothing if a datachannel wasn't offered
198
+ if ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp.includes('webrtc-datachannel')) {
199
+ this._log('info', 'creating data channel');
200
+ this.dataChannel = this.pc.createDataChannel('videoConferenceControl');
201
+ this.dataChannel.addEventListener('open', () => {
202
+ this._log('info', 'data channel opened');
203
+ });
204
+ this.dataChannel.addEventListener('message', this._handleDataChannelMessage.bind(this));
205
+ this.dataChannel.addEventListener('close', () => {
206
+ this._log('info', 'closing data channel');
207
+ });
208
+ this.dataChannel.addEventListener('error', (error) => {
209
+ this._log('error', 'Error occurred with the data channel', error);
210
+ });
211
+ }
212
+ }
213
+ _handleDataChannelMessage(event) {
214
+ this._log('debug', 'data channel message received', event);
215
+ try {
216
+ const message = JSON.parse(event.data);
217
+ this.emit('dataChannelMessage', message);
218
+ }
219
+ catch (e) {
220
+ this._log('error', 'Failed to parse data channel message', { error: e });
221
+ }
222
+ }
190
223
  }
@@ -4,9 +4,14 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
  # [Unreleased](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.2.0...HEAD)
7
+
8
+ ### Added
9
+ * [PCM-1972](https://inindca.atlassian.net/browse/PCM-1972) – Added support for data channel messages if initially offered in the sdp
10
+
7
11
  ### Fixed
8
12
  * [PCM-1963](https://inindca.atlassian.net/browse/PCM-1963) - Added missing error text from switch to Axios from SuperAgent.
9
13
 
14
+
10
15
  # [v14.2.0](https://github.com/purecloudlabs/genesys-cloud-streaming-client/compare/v14.1.2...v14.2.0)
11
16
  ### Added
12
17
  * [PCM-1944](https://inindca.atlassian.net/browse/PCM-1944) – Added reconnect options to the `streamingClient.connect` so it will continue to try to connect at a given interval. This is separate from the reconnection logic in the case where the client connected but disconnected unexpectedly.
@@ -118,3 +118,8 @@ export interface IPendingSession {
118
118
  accepted?: boolean;
119
119
  sessionType: SessionTypes | SessionTypesAsStrings;
120
120
  }
121
+ export interface JsonRpcMessage {
122
+ jsonrpc: string;
123
+ method: string;
124
+ params?: any;
125
+ }
@@ -6,7 +6,7 @@ import StrictEventEmitter from 'strict-event-emitter-types';
6
6
  import { EventEmitter } from 'events';
7
7
  import { JingleReason, JingleInfo, Jingle } from 'stanza/protocol';
8
8
  import { ActionCallback, SessionOpts } from 'stanza/jingle/Session';
9
- import { SessionTypes, SessionTypesAsStrings } from './interfaces';
9
+ import { JsonRpcMessage, SessionTypes, SessionTypesAsStrings } from './interfaces';
10
10
  export interface IGenesysCloudMediaSessionParams {
11
11
  options: SessionOpts;
12
12
  sessionType: SessionTypes | SessionTypesAsStrings;
@@ -30,6 +30,7 @@ export declare class GenesysCloudMediaSession extends MediaSession {
30
30
  ignoreHostCandidatesFromRemote: boolean;
31
31
  allowIPv6: boolean;
32
32
  allowTCP: boolean;
33
+ dataChannel?: RTCDataChannel;
33
34
  constructor(params: IGenesysCloudMediaSessionParams);
34
35
  private getLogDetails;
35
36
  onTransportInfo(changes: Jingle, cb: ActionCallback): Promise<void>;
@@ -42,6 +43,8 @@ export declare class GenesysCloudMediaSession extends MediaSession {
42
43
  onIceCandidate(e: RTCPeerConnectionIceEvent): void;
43
44
  onIceEndOfCandidates(): void;
44
45
  addTrack(track: MediaStreamTrack, stream?: MediaStream): Promise<void>;
46
+ _setupDataChannel(): void;
47
+ _handleDataChannelMessage(event: MessageEvent): void;
45
48
  }
46
49
  export interface SessionEvents {
47
50
  iceConnectionType: ({
@@ -58,6 +61,7 @@ export interface SessionEvents {
58
61
  terminated: JingleReason;
59
62
  stats: StatsEvent;
60
63
  endOfCandidates: void;
64
+ dataChannelMessage: JsonRpcMessage;
61
65
  }
62
66
  export interface GenesysCloudMediaSession extends StrictEventEmitter<EventEmitter, SessionEvents> {
63
67
  }
@@ -119,6 +119,7 @@ class GenesysCloudMediaSession extends jingle_1.MediaSession {
119
119
  infoType: Constants_1.JINGLE_INFO_ACTIVE
120
120
  }
121
121
  });
122
+ this._setupDataChannel();
122
123
  }
123
124
  else if (iceState === 'failed') {
124
125
  this._log('info', 'ICE connection failed', {
@@ -185,5 +186,37 @@ class GenesysCloudMediaSession extends jingle_1.MediaSession {
185
186
  return;
186
187
  });
187
188
  }
189
+ _setupDataChannel() {
190
+ var _a;
191
+ // this shouldn't happen, but we shouldn't set the datachannel up more than once
192
+ if (this.dataChannel) {
193
+ return;
194
+ }
195
+ // do nothing if a datachannel wasn't offered
196
+ if ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp.includes('webrtc-datachannel')) {
197
+ this._log('info', 'creating data channel');
198
+ this.dataChannel = this.pc.createDataChannel('videoConferenceControl');
199
+ this.dataChannel.addEventListener('open', () => {
200
+ this._log('info', 'data channel opened');
201
+ });
202
+ this.dataChannel.addEventListener('message', this._handleDataChannelMessage.bind(this));
203
+ this.dataChannel.addEventListener('close', () => {
204
+ this._log('info', 'closing data channel');
205
+ });
206
+ this.dataChannel.addEventListener('error', (error) => {
207
+ this._log('error', 'Error occurred with the data channel', error);
208
+ });
209
+ }
210
+ }
211
+ _handleDataChannelMessage(event) {
212
+ this._log('debug', 'data channel message received', event);
213
+ try {
214
+ const message = JSON.parse(event.data);
215
+ this.emit('dataChannelMessage', message);
216
+ }
217
+ catch (e) {
218
+ this._log('error', 'Failed to parse data channel message', { error: e });
219
+ }
220
+ }
188
221
  }
189
222
  exports.GenesysCloudMediaSession = GenesysCloudMediaSession;