@24i/bigscreen-sdk 1.0.34-alpha.2568 → 1.0.34-alpha.2570

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@24i/bigscreen-sdk",
3
- "version": "1.0.34-alpha.2568",
3
+ "version": "1.0.34-alpha.2570",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,10 +18,8 @@ import { LEFT, RIGHT, UP, DOWN, ENTER, BACK, ESC } from './KeyMap';
18
18
  export const STORAGE_UUID_KEY = '__UUID__';
19
19
 
20
20
  const DEFAULT_POLLING_INTERVAL = 15000;
21
- const DEFAULT_POLLING_TIMEOUT = 10000;
22
- const SUCCESS_STATUS_CODE = 200;
23
21
 
24
- const CHECK_STATE_URL = 'https://8.8.8.8/';
22
+ const CHECKED_URL = 'http://www.google-analytics.com/__utm.gif';
25
23
 
26
24
  export abstract class DeviceBase<
27
25
  CustomEventMap extends EventMapType = {},
@@ -50,8 +48,6 @@ export abstract class DeviceBase<
50
48
 
51
49
  pollingInterval: number = DEFAULT_POLLING_INTERVAL;
52
50
 
53
- pollingTimeout: number = DEFAULT_POLLING_TIMEOUT;
54
-
55
51
  // MARK: Initialization
56
52
 
57
53
  /**
@@ -84,27 +80,25 @@ export abstract class DeviceBase<
84
80
  }
85
81
 
86
82
  doOnlineCheck = () => {
87
- const http = new XMLHttpRequest();
88
- http.open('HEAD', `${CHECK_STATE_URL}?param=${Date.now()}`);
89
- http.timeout = this.pollingTimeout || DEFAULT_POLLING_TIMEOUT;
90
- http.onreadystatechange = () => {
91
- const isConnected = http.status === SUCCESS_STATUS_CODE;
92
- if (http.readyState === XMLHttpRequest.DONE) {
93
- this.triggerEvent('networkchange',
94
- { isConnected } as any);
95
- }
96
- };
97
- http.ontimeout = () => {
98
- this.triggerEvent('networkchange',
99
- { isConnected: false } as any);
100
- };
101
- http.send();
83
+ const tester = new Image();
84
+ tester.onload = this.connectionFound;
85
+ tester.onerror = this.connectionNotFound;
86
+ tester.src = `${CHECKED_URL}?ts=${Date.now()}`;
87
+ };
88
+
89
+ connectionFound = () => {
90
+ this.triggerEvent('networkchange',
91
+ { isConnected: true } as any);
92
+ };
93
+
94
+ connectionNotFound = () => {
95
+ this.triggerEvent('networkchange',
96
+ { isConnected: false } as any);
102
97
  };
103
98
 
104
99
  checkNetworkConnection() {
105
100
  const networkConfig: any = config.get('network.checkConnection');
106
101
  this.pollingInterval = Number(networkConfig?.pollingInterval);
107
- this.pollingTimeout = Number(networkConfig?.pollingTimeout);
108
102
  window.setInterval(
109
103
  this.doOnlineCheck,
110
104
  this.pollingInterval || DEFAULT_POLLING_INTERVAL,