@24i/bigscreen-sdk 1.0.34-alpha.2567 → 1.0.34-alpha.2569

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.2567",
3
+ "version": "1.0.34-alpha.2569",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,8 +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;
21
+
22
+ const CHECKED_URL = 'http://www.google-analytics.com/__utm.gif';
23
23
 
24
24
  export abstract class DeviceBase<
25
25
  CustomEventMap extends EventMapType = {},
@@ -48,8 +48,6 @@ export abstract class DeviceBase<
48
48
 
49
49
  pollingInterval: number = DEFAULT_POLLING_INTERVAL;
50
50
 
51
- pollingTimeout: number = DEFAULT_POLLING_TIMEOUT;
52
-
53
51
  // MARK: Initialization
54
52
 
55
53
  /**
@@ -81,28 +79,26 @@ export abstract class DeviceBase<
81
79
  return this.initializer;
82
80
  }
83
81
 
84
- doOnlineCheck = () => {
85
- const http = new XMLHttpRequest();
86
- http.open('HEAD', `${document.location.pathname}?param=${Date.now()}`);
87
- http.timeout = this.pollingTimeout || DEFAULT_POLLING_TIMEOUT;
88
- http.onreadystatechange = () => {
89
- const isConnected = http.status === SUCCESS_STATUS_CODE;
90
- if (http.readyState === XMLHttpRequest.DONE) {
91
- this.triggerEvent('networkchange',
92
- { isConnected } as any);
93
- }
94
- };
95
- http.ontimeout = () => {
96
- this.triggerEvent('networkchange',
97
- { isConnected: false } as any);
98
- };
99
- http.send();
82
+ doOnlineCheck() {
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);
100
97
  };
101
98
 
102
99
  checkNetworkConnection() {
103
100
  const networkConfig: any = config.get('network.checkConnection');
104
101
  this.pollingInterval = Number(networkConfig?.pollingInterval);
105
- this.pollingTimeout = Number(networkConfig?.pollingTimeout);
106
102
  window.setInterval(
107
103
  this.doOnlineCheck,
108
104
  this.pollingInterval || DEFAULT_POLLING_INTERVAL,