senza-sdk 4.2.65-a3f8c5a.0 → 4.3.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/dist/bundle.js +1 -1
- package/dist/bundle.js.LICENSE.txt +0 -4
- package/dist/implementation.bundle.js +2 -0
- package/dist/implementation.bundle.js.LICENSE.txt +57 -0
- package/package.json +16 -8
- package/src/api.js +258 -327
- package/src/{alarmManager.js → implementation/alarmManager.js} +15 -52
- package/src/implementation/api.js +363 -0
- package/src/{deviceManager.js → implementation/deviceManager.js} +6 -78
- package/src/{lifecycle.js → implementation/lifecycle.js} +14 -192
- package/src/implementation/messageManager.js +55 -0
- package/src/{platformManager.js → implementation/platformManager.js} +5 -23
- package/src/{remotePlayer.js → implementation/remotePlayer.js} +5 -276
- package/src/{senzaShakaPlayer.js → implementation/senzaShakaPlayer.js} +8 -120
- package/src/{utils.js → implementation/utils.js} +15 -6
- package/src/interface/alarmManager.js +76 -0
- package/src/interface/api.js +8 -0
- package/src/interface/deviceManager.js +143 -0
- package/src/interface/lifecycle.js +284 -0
- package/src/interface/messageManager.js +54 -0
- package/src/interface/platformManager.js +42 -0
- package/src/interface/remotePlayer.js +469 -0
- package/src/interface/senzaShakaPlayer.js +168 -0
- package/src/interface/utils.js +45 -0
- package/src/messageManager.js +0 -88
- /package/src/{SessionInfo.js → implementation/SessionInfo.js} +0 -0
- /package/src/{devHelper.js → implementation/devHelper.js} +0 -0
- /package/src/{eventListenersManager.js → implementation/eventListenersManager.js} +0 -0
- /package/src/{subtitlesUtils.js → implementation/subtitlesUtils.js} +0 -0
- /package/src/{devSequence.js → interface/devSequence.js} +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lifecycle as LifecycleInterface } from "../interface/lifecycle";
|
|
2
|
+
import { getPlatformInfo } from "./api";
|
|
3
|
+
import { alarmManager } from "./alarmManager";
|
|
2
4
|
import {
|
|
3
5
|
getFCID,
|
|
4
6
|
isAudioSyncConfigured,
|
|
@@ -18,82 +20,7 @@ const DEFAULT_AUTO_BACKGROUND_VIDEO_DELAY = 30;
|
|
|
18
20
|
const DEFAULT_AUTO_BACKGROUND_UI_DELAY = -1;
|
|
19
21
|
const DEFAULT_AUTO_BACKGROUND_ENABLED = false;
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
* Lifecycle is a singleton class that manages the application lifecycle states.<br>
|
|
23
|
-
* @fires onstatechange
|
|
24
|
-
* @fires userinactivity
|
|
25
|
-
* @fires userdisconnected
|
|
26
|
-
*/
|
|
27
|
-
class Lifecycle extends EventTarget {
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {Object} ConnectReason - The reason the ui app has been loaded
|
|
31
|
-
* @property {string} UNKNOWN
|
|
32
|
-
* @property {string} INITIAL_CONNECTION - Indicates that ui app has been loaded for the first time
|
|
33
|
-
* @property {string} APPLICATION_RELOAD - Indicates that ui app has been reloaded (e.g. after HOME keypress)
|
|
34
|
-
* @property {string} UI_RELEASE - Indicates that ui app has been reloaded after ui release
|
|
35
|
-
* @property {string} UI_TERMINATION - Indicates that ui app has been reloaded due to ui termination
|
|
36
|
-
* @property {string} WEBRTC_ERROR - Indicates that ui app has been reloaded due to webrtc error
|
|
37
|
-
* @property {string} UI_WATCHDOG - Indicates that ui app has been reloaded due to ui watchdog not receiving ui frames
|
|
38
|
-
*/
|
|
39
|
-
ConnectReason = Object.freeze({
|
|
40
|
-
UNKNOWN: "unknown",
|
|
41
|
-
INITIAL_CONNECTION: "initial_connection",
|
|
42
|
-
APPLICATION_RELOAD: "reload_app",
|
|
43
|
-
UI_RELEASE: "ui_release",
|
|
44
|
-
UI_TERMINATION: "ui_termination",
|
|
45
|
-
WEBRTC_ERROR: "webrtc_error",
|
|
46
|
-
UI_WATCHDOG: "ui_watchdog"
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @typedef {Object} UiState - The ui lifecycle state
|
|
51
|
-
* @property {string} UNKNOWN - state is unknown at this time
|
|
52
|
-
* @property {string} FOREGROUND - ui is displayed
|
|
53
|
-
* @property {string} IN_TRANSITION_TO_FOREGROUND - ui is about to be displayed
|
|
54
|
-
* @property {string} BACKGROUND - remote player is playing (full screen playback is displayed)
|
|
55
|
-
* @property {string} IN_TRANSITION_TO_BACKGROUND - remote player is about to be playing
|
|
56
|
-
*/
|
|
57
|
-
UiState = Object.freeze({
|
|
58
|
-
UNKNOWN: "unknown",
|
|
59
|
-
FOREGROUND: "foreground",
|
|
60
|
-
IN_TRANSITION_TO_FOREGROUND: "inTransitionToForeground",
|
|
61
|
-
BACKGROUND: "background",
|
|
62
|
-
IN_TRANSITION_TO_BACKGROUND: "inTransitionToBackground"
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* @event Lifecycle#onstatechange
|
|
67
|
-
* @description Fired after transition from one state to another.<br>
|
|
68
|
-
* The flow is: foreground --> inTransitionToBackground --> background --> inTransitionToForeground --> foreground
|
|
69
|
-
* @property {UiState} state - Indicates the new state.
|
|
70
|
-
* @example
|
|
71
|
-
* lifecycle.addEventListener("onstatechange", (e) => {
|
|
72
|
-
* console.log("new state is", e.state);
|
|
73
|
-
* });
|
|
74
|
-
*/
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @event Lifecycle#userinactivity
|
|
78
|
-
* @description Fired after the ui has been inactive (i.e. no key presses) for a configurable number of seconds.<br>
|
|
79
|
-
* @property {number} timeout - the number of seconds after which the application will be unloaded.
|
|
80
|
-
* @example
|
|
81
|
-
* lifecycle.addEventListener("userinactivity", (e) => {
|
|
82
|
-
* console.log(`Application will be unloaded in ${e.timeout} seconds`);
|
|
83
|
-
* });
|
|
84
|
-
* @alpha API has not yet been released
|
|
85
|
-
*/
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @event Lifecycle#userdisconnected
|
|
89
|
-
* @description Fired when the user session ends .
|
|
90
|
-
* This event is useful for cleaning up application state or saving data before the application closes. Event callback should return promise to ensure that the event is handled before the application is terminated
|
|
91
|
-
* @example
|
|
92
|
-
* lifecycle.addEventListener("userdisconnected", () => {
|
|
93
|
-
* console.log("User session ended, cleaning up application state");
|
|
94
|
-
* // Perform any necessary cleanup here
|
|
95
|
-
* });
|
|
96
|
-
*/
|
|
23
|
+
class Lifecycle extends LifecycleInterface {
|
|
97
24
|
constructor() {
|
|
98
25
|
super();
|
|
99
26
|
|
|
@@ -179,7 +106,8 @@ class Lifecycle extends EventTarget {
|
|
|
179
106
|
});
|
|
180
107
|
}
|
|
181
108
|
|
|
182
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* @private Initialize the lifecycle
|
|
183
111
|
* @param {Object} uiStreamerSettings - UI-streamer portion of the settings taken from session info
|
|
184
112
|
* @param {Object} [uiStreamerSettings.autoBackground] - Auto background mode configuration
|
|
185
113
|
* @param {boolean} [uiStreamerSettings.autoBackground.enabled=false] - Enable/disable auto background
|
|
@@ -276,14 +204,16 @@ class Lifecycle extends EventTarget {
|
|
|
276
204
|
}
|
|
277
205
|
}
|
|
278
206
|
|
|
279
|
-
/**
|
|
207
|
+
/**
|
|
208
|
+
* @private Checks if auto background is enabled including overrides.
|
|
280
209
|
* @returns {boolean}
|
|
281
210
|
*/
|
|
282
211
|
_isAutoBackgroundEnabled() {
|
|
283
212
|
return this._autoBackgroundOverrides?.enabled ?? this._autoBackground;
|
|
284
213
|
}
|
|
285
214
|
|
|
286
|
-
/**
|
|
215
|
+
/**
|
|
216
|
+
* @private Gets the auto background video delay including overrides.
|
|
287
217
|
* @returns {number}
|
|
288
218
|
*/
|
|
289
219
|
_getAutoBackgroundOnVideoDelay() {
|
|
@@ -294,7 +224,8 @@ class Lifecycle extends EventTarget {
|
|
|
294
224
|
return this._autoBackgroundOnVideoDelay;
|
|
295
225
|
}
|
|
296
226
|
|
|
297
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* @private Gets the auto background UI delay including overrides.
|
|
298
229
|
* @returns {number}
|
|
299
230
|
*/
|
|
300
231
|
_getAutoBackgroundOnUIDelay() {
|
|
@@ -305,15 +236,6 @@ class Lifecycle extends EventTarget {
|
|
|
305
236
|
return this._autoBackgroundOnUIDelay;
|
|
306
237
|
}
|
|
307
238
|
|
|
308
|
-
/**
|
|
309
|
-
* Configure lifecycle settings
|
|
310
|
-
* @param {Object} config - Configuration object
|
|
311
|
-
* @param {Object} [config.autoBackground] - Auto background settings
|
|
312
|
-
* @param {boolean} [config.autoBackground.enabled] - Enable/disable auto background
|
|
313
|
-
* @param {Object} [config.autoBackground.timeout] - Timeout settings
|
|
314
|
-
* @param {number|false} [config.autoBackground.timeout.playing=30] - Timeout in seconds when video is playing, false to disable
|
|
315
|
-
* @param {number|false} [config.autoBackground.timeout.idle=false] - Timeout in seconds when in UI mode, false to disable
|
|
316
|
-
*/
|
|
317
239
|
configure(config) {
|
|
318
240
|
if (config?.autoBackground) {
|
|
319
241
|
const { enabled, timeout } = config.autoBackground;
|
|
@@ -353,15 +275,6 @@ class Lifecycle extends EventTarget {
|
|
|
353
275
|
}
|
|
354
276
|
}
|
|
355
277
|
|
|
356
|
-
/**
|
|
357
|
-
* Get the current configuration settings
|
|
358
|
-
* @returns {Object} The current configuration object
|
|
359
|
-
* @example
|
|
360
|
-
* const config = lifecycle.getConfiguration();
|
|
361
|
-
* console.log(config.autoBackground.enabled); // true/false
|
|
362
|
-
* console.log(config.autoBackground.timeout.playing); // 30
|
|
363
|
-
* console.log(config.autoBackground.timeout.idle); // false
|
|
364
|
-
*/
|
|
365
278
|
getConfiguration() {
|
|
366
279
|
return {
|
|
367
280
|
autoBackground: {
|
|
@@ -375,6 +288,7 @@ class Lifecycle extends EventTarget {
|
|
|
375
288
|
}
|
|
376
289
|
|
|
377
290
|
/**
|
|
291
|
+
* @private
|
|
378
292
|
* This method moves the application into standby mode, i.e. last ui frame is displayed and ui resources are released.
|
|
379
293
|
* It should be called whenever the application wishes to go into standby mode and release resources.
|
|
380
294
|
* @example
|
|
@@ -410,10 +324,6 @@ class Lifecycle extends EventTarget {
|
|
|
410
324
|
return Promise.resolve(true);
|
|
411
325
|
}
|
|
412
326
|
|
|
413
|
-
/**
|
|
414
|
-
* Getter for returning the ui lifecycle state
|
|
415
|
-
* @returns {UiState} the current application lifecycle state
|
|
416
|
-
*/
|
|
417
327
|
get state() {
|
|
418
328
|
if (!this._isInitialized) {
|
|
419
329
|
this._state = this.UiState.UNKNOWN;
|
|
@@ -421,10 +331,6 @@ class Lifecycle extends EventTarget {
|
|
|
421
331
|
return this._state;
|
|
422
332
|
}
|
|
423
333
|
|
|
424
|
-
/**
|
|
425
|
-
* Getter for returning the application connection reason
|
|
426
|
-
* @returns {ConnectReason} the application connection reason
|
|
427
|
-
*/
|
|
428
334
|
get connectReason() {
|
|
429
335
|
if (!this._isInitialized) {
|
|
430
336
|
this._connectReason = this.ConnectReason.UNKNOWN;
|
|
@@ -432,11 +338,6 @@ class Lifecycle extends EventTarget {
|
|
|
432
338
|
return this._connectReason;
|
|
433
339
|
}
|
|
434
340
|
|
|
435
|
-
/**
|
|
436
|
-
* Getter for returning the event that triggered the reloading of the ui after ui has been released
|
|
437
|
-
* @returns {Object} trigger event
|
|
438
|
-
* @property {string} type - the type of the trigger event (e.g. keyPressEvent, videoPlaybackEvent)
|
|
439
|
-
* @property {object} data - data of the event, dependent on its type (e.g. keyPressEvent has data of keyValue) */
|
|
440
341
|
get triggerEvent() {
|
|
441
342
|
if (!this._isInitialized) {
|
|
442
343
|
this._triggerEvent = {};
|
|
@@ -444,14 +345,6 @@ class Lifecycle extends EventTarget {
|
|
|
444
345
|
return this._triggerEvent;
|
|
445
346
|
}
|
|
446
347
|
|
|
447
|
-
/**
|
|
448
|
-
* @deprecated Use `lifecycle.configure()` instead.
|
|
449
|
-
* Controls the autoBackground feature.<br>
|
|
450
|
-
* When enabled, the application will automatically move to the background state after a configurable
|
|
451
|
-
* period of inactivity. Use the `configure` method to set timeouts for video playback and UI states.
|
|
452
|
-
* @type {boolean}
|
|
453
|
-
* @see {@link Lifecycle#configure}
|
|
454
|
-
*/
|
|
455
348
|
set autoBackground(enabled) {
|
|
456
349
|
this._autoBackground = enabled;
|
|
457
350
|
if (this._isAutoBackgroundEnabled()) {
|
|
@@ -465,14 +358,6 @@ class Lifecycle extends EventTarget {
|
|
|
465
358
|
return this._autoBackground;
|
|
466
359
|
}
|
|
467
360
|
|
|
468
|
-
/**
|
|
469
|
-
* @deprecated Use `lifecycle.configure()` instead.
|
|
470
|
-
* The number of seconds of user inactivity before the application moves to the background state while playing video.
|
|
471
|
-
* Use the `configure` method to set this timeout.
|
|
472
|
-
* @type {integer}
|
|
473
|
-
* @default 30
|
|
474
|
-
* @see {@link Lifecycle#configure}
|
|
475
|
-
*/
|
|
476
361
|
set autoBackgroundDelay(delay) {
|
|
477
362
|
this._autoBackgroundOnVideoDelay = delay;
|
|
478
363
|
if (this._isAutoBackgroundEnabled() && remotePlayer._isPlaying) {
|
|
@@ -484,14 +369,6 @@ class Lifecycle extends EventTarget {
|
|
|
484
369
|
return this._autoBackgroundOnVideoDelay;
|
|
485
370
|
}
|
|
486
371
|
|
|
487
|
-
/**
|
|
488
|
-
* @deprecated Use `lifecycle.configure()` instead.
|
|
489
|
-
* The number of seconds of user inactivity before the application moves to the background state while in the UI (not playing).
|
|
490
|
-
* Use the `configure` method to set this timeout.
|
|
491
|
-
* @type {integer}
|
|
492
|
-
* @default -1
|
|
493
|
-
* @see {@link Lifecycle#configure}
|
|
494
|
-
*/
|
|
495
372
|
set autoBackgroundOnUIDelay(delay) {
|
|
496
373
|
this._autoBackgroundOnUIDelay = delay;
|
|
497
374
|
if (this._isAutoBackgroundEnabled() && !remotePlayer._isPlaying) {
|
|
@@ -534,18 +411,6 @@ class Lifecycle extends EventTarget {
|
|
|
534
411
|
this._countdown = null;
|
|
535
412
|
}
|
|
536
413
|
|
|
537
|
-
/**
|
|
538
|
-
* @deprecated use lifecycle.state instead.
|
|
539
|
-
* Async function that returns the ui lifecycle state
|
|
540
|
-
* @returns {UiState} the current application lifecycle state
|
|
541
|
-
* @example
|
|
542
|
-
* try {
|
|
543
|
-
* const state = await lifecycle.getState();
|
|
544
|
-
* console.log("current state is", state);
|
|
545
|
-
* } catch (e) {
|
|
546
|
-
* console.error("getState failed", e);
|
|
547
|
-
* }
|
|
548
|
-
*/
|
|
549
414
|
getState() {
|
|
550
415
|
if (window.cefQuery) {
|
|
551
416
|
return new Promise((resolve, reject) => {
|
|
@@ -566,14 +431,6 @@ class Lifecycle extends EventTarget {
|
|
|
566
431
|
sdkLogger.warn("lifecycle getState is not supported if NOT running e2e");
|
|
567
432
|
}
|
|
568
433
|
|
|
569
|
-
/**
|
|
570
|
-
* Once playback starts on the remote player,
|
|
571
|
-
* the application is moved from foreground to inTransitionToBackground and eventually to background.
|
|
572
|
-
* The application will need to call moveToForeground when it receives an event that needs the UI to be displayed again,
|
|
573
|
-
* for example a key press, a playback end-of-file or a playback error.
|
|
574
|
-
* @return {Promise} Promise which is resolved when the moveToForeground command has been successfully processed.
|
|
575
|
-
* Failure to process the moveToForeground command will result in the promise being rejected.
|
|
576
|
-
*/
|
|
577
434
|
moveToForeground() {
|
|
578
435
|
if (window.cefQuery) {
|
|
579
436
|
if (this._inTransition || this._state === this.UiState.FOREGROUND || this._state === this.UiState.IN_TRANSITION_TO_FOREGROUND) {
|
|
@@ -735,17 +592,6 @@ class Lifecycle extends EventTarget {
|
|
|
735
592
|
return Promise.resolve(false);
|
|
736
593
|
}
|
|
737
594
|
|
|
738
|
-
/**
|
|
739
|
-
* This method moves the application to the background.
|
|
740
|
-
* It should be called after remotePlayer.play().
|
|
741
|
-
* As a consequence, remote player playback will be displayed in full screen.
|
|
742
|
-
* @example
|
|
743
|
-
* remotePlayer.load("https://example.com/video.mp4", 0);
|
|
744
|
-
* remotePlayer.play();
|
|
745
|
-
* lifecycle.moveToBackground();
|
|
746
|
-
* @return {Promise} Promise which is resolved when the moveToBackground command has been successfully processed.
|
|
747
|
-
* Failure to process the moveToBackground command will result in the promise being rejected.
|
|
748
|
-
*/
|
|
749
595
|
moveToBackground() {
|
|
750
596
|
if (window.cefQuery) {
|
|
751
597
|
if (this._inTransition || this._state === this.UiState.BACKGROUND || this._state === this.UiState.IN_TRANSITION_TO_BACKGROUND) {
|
|
@@ -769,13 +615,6 @@ class Lifecycle extends EventTarget {
|
|
|
769
615
|
return this._moveToBackground();
|
|
770
616
|
}
|
|
771
617
|
|
|
772
|
-
/**
|
|
773
|
-
* Use this api to switch to another tenant (other than the home tenant) which will launch the application associated with the tenantId. The tenantId must be configured in the
|
|
774
|
-
* Senza platform. Switching to the home tenant should use the exitApplication().
|
|
775
|
-
* @param {string} tenantId The tenantId to switch
|
|
776
|
-
* @return {Promise} Promise which is resolved when the switchTenant command has been successfully processed.
|
|
777
|
-
* Failure to process the switchTenant command will result in the promise being rejected.
|
|
778
|
-
*/
|
|
779
618
|
switchTenant(tenantId) {
|
|
780
619
|
if (tenantId && tenantId.length > 0) {
|
|
781
620
|
if (tenantId === getPlatformInfo().sessionInfo?.tenantId) {
|
|
@@ -784,7 +623,6 @@ class Lifecycle extends EventTarget {
|
|
|
784
623
|
}
|
|
785
624
|
|
|
786
625
|
// TODO: Need to discuss checking for a valid tenantId in the Senza platform
|
|
787
|
-
remotePlayer._blackoutTime = undefined;
|
|
788
626
|
const contentHubTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantInfo?.contentHubTenantId;
|
|
789
627
|
const homeTenantId = getPlatformInfo().sessionInfo?.homeSessionInfo?.tenantId;
|
|
790
628
|
sdkLogger.log(`SwitchTenant for ${tenantId}`);
|
|
@@ -822,11 +660,6 @@ class Lifecycle extends EventTarget {
|
|
|
822
660
|
return Promise.reject("SwitchTenant requires a valid tenantId string parameter");
|
|
823
661
|
}
|
|
824
662
|
|
|
825
|
-
/**
|
|
826
|
-
* Use this api to exit the application which will redirect the browser to the home tenant application.
|
|
827
|
-
* @return {Promise} Promise which is resolved when the exitApplication command has been successfully processed.
|
|
828
|
-
* Failure to process the exitApplication command will result in the promise being rejected.
|
|
829
|
-
*/
|
|
830
663
|
exitApplication() {
|
|
831
664
|
if (window.cefQuery) {
|
|
832
665
|
return new Promise((resolve, reject) => {
|
|
@@ -875,12 +708,6 @@ class Lifecycle extends EventTarget {
|
|
|
875
708
|
return Promise.reject("exitApplication is not supported if NOT running e2e");
|
|
876
709
|
}
|
|
877
710
|
|
|
878
|
-
/**
|
|
879
|
-
* Add event listener for lifecycle events
|
|
880
|
-
* @param {string} type - The event type to listen for
|
|
881
|
-
* @param {Function} listener - The callback function. Listeners for 'userdisconnected' events should return a promise to ensure the event is processed before the application exits.
|
|
882
|
-
* @param {Object} options - Event listener options
|
|
883
|
-
*/
|
|
884
711
|
addEventListener(type, listener, options) {
|
|
885
712
|
if (type === "userdisconnected") {
|
|
886
713
|
// Use the event manager for userdisconnected events
|
|
@@ -891,12 +718,7 @@ class Lifecycle extends EventTarget {
|
|
|
891
718
|
}
|
|
892
719
|
}
|
|
893
720
|
|
|
894
|
-
|
|
895
|
-
* Remove event listener
|
|
896
|
-
* @param {string} type - The event type
|
|
897
|
-
* @param {Function} listener - The callback function to remove
|
|
898
|
-
* @param {Object} options - Event listener options
|
|
899
|
-
*/
|
|
721
|
+
|
|
900
722
|
removeEventListener(type, listener, options) {
|
|
901
723
|
if (type === "userdisconnected") {
|
|
902
724
|
// Use the event manager for userdisconnected events
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { MessageManager as MessageManagerInterface } from "../interface/messageManager";
|
|
2
|
+
import { getFCID, sdkLogger } from "./utils";
|
|
3
|
+
|
|
4
|
+
class MessageManager extends MessageManagerInterface {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
typeof document !== "undefined" && document.addEventListener("hs/externalEvent", (e) => {
|
|
9
|
+
sdkLogger.log("Got hs/externalEvent", JSON.stringify(e.detail));
|
|
10
|
+
this.dispatchEvent(new CustomEvent("message", { detail: { eventName: e.detail.eventName, payload: e.detail.payload, fcid: e.detail.fcid } }));
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
async registerGroups(groups) {
|
|
15
|
+
sdkLogger.log(`register called for ${groups}`);
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
if (window.cefQuery) {
|
|
18
|
+
const FCID = getFCID();
|
|
19
|
+
const logger = sdkLogger.withFields({ FCID });
|
|
20
|
+
const message = {
|
|
21
|
+
type: "registerGroupEvent",
|
|
22
|
+
fcid: FCID,
|
|
23
|
+
groups
|
|
24
|
+
};
|
|
25
|
+
const request = { target: "UI-Streamer", waitForResponse: false, message: JSON.stringify(message) };
|
|
26
|
+
window.cefQuery({
|
|
27
|
+
request: JSON.stringify(request),
|
|
28
|
+
persistent: false,
|
|
29
|
+
onSuccess: () => {
|
|
30
|
+
logger.log("registerGroupEvent request successfully sent");
|
|
31
|
+
resolve(true);
|
|
32
|
+
},
|
|
33
|
+
onFailure: (code, msg) => {
|
|
34
|
+
logger.error(`registerGroupEvent failed: ${code} ${msg}`);
|
|
35
|
+
reject(`registerGroupEvent failed: ${code} ${msg}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
sdkLogger.warn("registerGroupEvent is not supported if NOT running e2e");
|
|
40
|
+
reject("registerGroupEvent is not supported if NOT running e2e");
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
*
|
|
48
|
+
* @module
|
|
49
|
+
* @example
|
|
50
|
+
* import { MessageManager } from "senza-sdk";
|
|
51
|
+
*
|
|
52
|
+
* @return {MessageManager} pointer to the MessageManager singleton
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
export const messageManager = new MessageManager();
|
|
@@ -1,41 +1,23 @@
|
|
|
1
|
+
import { PlatformManager as PlatformManagerInterface } from "../interface/platformManager";
|
|
1
2
|
import { sdkLogger } from "./utils";
|
|
2
|
-
import {sessionInfo} from "./SessionInfo";
|
|
3
|
+
import { sessionInfo } from "./SessionInfo";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* PlatformManager is a singleton class that manages the platform
|
|
7
|
-
*/
|
|
8
|
-
class PlatformManager extends EventTarget {
|
|
5
|
+
class PlatformManager extends PlatformManagerInterface {
|
|
9
6
|
|
|
10
7
|
constructor() {
|
|
11
8
|
super();
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
/**
|
|
15
|
-
* @returns {Object} appConfig object
|
|
16
|
-
* @property {String[]} territories - a list of territories configured for the tenant.
|
|
17
|
-
* if the list is undefined or empty - there are no restrictions.
|
|
18
|
-
* @example
|
|
19
|
-
* import { platformManager } from "senza-sdk";
|
|
20
|
-
* const appConfig = platformManager.appConfig
|
|
21
|
-
* */
|
|
22
11
|
get appConfig() {
|
|
23
12
|
const sessionInfoObj = sessionInfo.sessionInfoObj;
|
|
24
13
|
const appConfig = sessionInfoObj.homeSessionInfo?.["appConfig"] || {};
|
|
25
|
-
sdkLogger.info("PlatformManager get appConfig: \n" + JSON.stringify(appConfig, null,2));
|
|
14
|
+
sdkLogger.info("PlatformManager get appConfig: \n" + JSON.stringify(appConfig, null, 2));
|
|
26
15
|
return appConfig;
|
|
27
16
|
}
|
|
28
17
|
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @param {string} timezone the timezone to set to
|
|
32
|
-
* the format of the timezone is according to the standard TZ identifier
|
|
33
|
-
* (e.g. America/Los_Angeles, Asia/Tokyo, Europe/Brussels)
|
|
34
|
-
* for a full list of TZ identifiers, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
|
35
|
-
*/
|
|
36
18
|
setTimezone(timezone) {
|
|
37
19
|
if (window.cefQuery) {
|
|
38
|
-
const request = {message: JSON.stringify({type: "setTimeZone", timezone}), waitForResponse: false, target: "UI-Streamer"};
|
|
20
|
+
const request = { message: JSON.stringify({ type: "setTimeZone", timezone }), waitForResponse: false, target: "UI-Streamer" };
|
|
39
21
|
window.cefQuery({
|
|
40
22
|
request: JSON.stringify(request),
|
|
41
23
|
persistent: false,
|