homebridge-xbox-tv 2.8.21 → 2.8.22-beta.1
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 +1 -1
- package/src/webApi/xboxwebapi.js +21 -15
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "Xbox TV",
|
|
3
3
|
"name": "homebridge-xbox-tv",
|
|
4
|
-
"version": "2.8.
|
|
4
|
+
"version": "2.8.22-beta.1",
|
|
5
5
|
"description": "Homebridge plugin (https://github.com/homebridge/homebridge) to control Xbox game consoles.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -42,20 +42,15 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
42
42
|
//variables
|
|
43
43
|
this.authorized = false;
|
|
44
44
|
|
|
45
|
-
this.
|
|
46
|
-
await new Promise(resolve => setTimeout(resolve, 5000));
|
|
47
|
-
this.emit('stateChanged', false);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
this.getAuthorizationState();
|
|
45
|
+
this.checkAuthorization();
|
|
51
46
|
}
|
|
52
47
|
|
|
53
48
|
async updateAuthorization() {
|
|
54
49
|
await new Promise(resolve => setTimeout(resolve, 900000));
|
|
55
|
-
this.
|
|
50
|
+
this.checkAuthorization();
|
|
56
51
|
};
|
|
57
52
|
|
|
58
|
-
async
|
|
53
|
+
async checkAuthorization() {
|
|
59
54
|
try {
|
|
60
55
|
const tokens = this.userToken && this.userHash ? false : await this.authentication.checkAuthorization();
|
|
61
56
|
const debug = this.debugLog ? this.emit('debug', `authorization tokens: ${JSON.stringify(tokens, null, 2)}`) : false;
|
|
@@ -72,6 +67,21 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
72
67
|
this.tokens = tokens;
|
|
73
68
|
this.authorized = true;
|
|
74
69
|
|
|
70
|
+
try {
|
|
71
|
+
await this.xboxLiveData();
|
|
72
|
+
} catch (error) {
|
|
73
|
+
this.emit('error', `xbox live data error: ${JSON.stringify(error, null, 2)}.`);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
this.updateAuthorization();
|
|
77
|
+
} catch (error) {
|
|
78
|
+
this.emit('error', `check authorization state error: ${JSON.stringify(error, null, 2)}, recheck in 15min.`);
|
|
79
|
+
this.updateAuthorization();
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
xboxLiveData() {
|
|
84
|
+
return new Promise(async (resolve, reject) => {
|
|
75
85
|
try {
|
|
76
86
|
const rmEnabled = await this.consoleStatus();
|
|
77
87
|
const debug1 = !rmEnabled ? this.emit('message', `remote management not enabled, please check your console settings.`) : false;
|
|
@@ -79,15 +89,11 @@ class XBOXWEBAPI extends EventEmitter {
|
|
|
79
89
|
await this.installedApps();
|
|
80
90
|
//await this.storageDevices();
|
|
81
91
|
//await this.userProfile();
|
|
82
|
-
|
|
92
|
+
resolve();
|
|
83
93
|
} catch (error) {
|
|
84
|
-
this.
|
|
85
|
-
this.updateAuthorization();
|
|
94
|
+
reject(`Console: ${this.xboxLiveId}, get data error: ${JSON.stringify(error, null, 2)}`);
|
|
86
95
|
};
|
|
87
|
-
}
|
|
88
|
-
this.emit('error', `check authorization state error: ${JSON.stringify(error, null, 2)}, recheck in 15min.`);
|
|
89
|
-
this.updateAuthorization();
|
|
90
|
-
};
|
|
96
|
+
});
|
|
91
97
|
};
|
|
92
98
|
|
|
93
99
|
consoleStatus() {
|