homebridge-xbox-tv 3.3.4-beta.1 → 3.3.4-beta.2
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 -23
package/package.json
CHANGED
package/src/webApi/xboxwebapi.js
CHANGED
|
@@ -17,6 +17,7 @@ class XboxWebApi extends EventEmitter {
|
|
|
17
17
|
|
|
18
18
|
//variables
|
|
19
19
|
this.authorized = false;
|
|
20
|
+
this.rmEnabled = false;
|
|
20
21
|
|
|
21
22
|
const authConfig = {
|
|
22
23
|
webApiClientId: config.webApiClientId,
|
|
@@ -55,15 +56,27 @@ class XboxWebApi extends EventEmitter {
|
|
|
55
56
|
this.tokens = data.tokens;
|
|
56
57
|
this.authorized = true;
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
59
|
+
if (!this.authorized) {
|
|
60
|
+
this.emit('warn', `not authorized`);
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
63
|
|
|
64
64
|
//check xbox live data
|
|
65
65
|
try {
|
|
66
|
-
|
|
66
|
+
//create axios instance
|
|
67
|
+
this.axiosInstance = axios.create({
|
|
68
|
+
method: 'GET',
|
|
69
|
+
headers: headers
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const rmEnabled = await this.consoleStatus();
|
|
73
|
+
const debug1 = rmEnabled ? false : this.emit('info', `Remote management not enabled, please check your console settings`);
|
|
74
|
+
this.rmEnabled = rmEnabled;
|
|
75
|
+
|
|
76
|
+
//await this.consolesList();
|
|
77
|
+
await this.installedApps();
|
|
78
|
+
//await this.storageDevices();
|
|
79
|
+
//await this.userProfile();
|
|
67
80
|
} catch (error) {
|
|
68
81
|
this.emit('error', `Check xbox live data error: ${error}`);
|
|
69
82
|
};
|
|
@@ -74,21 +87,6 @@ class XboxWebApi extends EventEmitter {
|
|
|
74
87
|
};
|
|
75
88
|
}
|
|
76
89
|
|
|
77
|
-
async xboxLiveData() {
|
|
78
|
-
try {
|
|
79
|
-
const rmEnabled = await this.consoleStatus();
|
|
80
|
-
const debug1 = !rmEnabled ? this.emit('info', `Remote management not enabled, please check your console settings`) : false;
|
|
81
|
-
//await this.consolesList();
|
|
82
|
-
await this.installedApps();
|
|
83
|
-
//await this.storageDevices();
|
|
84
|
-
//await this.userProfile();
|
|
85
|
-
|
|
86
|
-
return true;
|
|
87
|
-
} catch (error) {
|
|
88
|
-
throw new Error(`Xbox live data error: ${error}`);
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
|
|
92
90
|
async consoleStatus() {
|
|
93
91
|
try {
|
|
94
92
|
const url = `${WebApi.Url.Xccs}/consoles/${this.xboxLiveId}`;
|
|
@@ -399,8 +397,8 @@ class XboxWebApi extends EventEmitter {
|
|
|
399
397
|
}
|
|
400
398
|
|
|
401
399
|
async send(commandType, command, payload) {
|
|
402
|
-
if (!this.authorized) {
|
|
403
|
-
this.emit('warn', `not authorized`);
|
|
400
|
+
if (!this.authorized || !this.rmEnabled) {
|
|
401
|
+
this.emit('warn', `not authorized or remote management not enabled`);
|
|
404
402
|
return;
|
|
405
403
|
};
|
|
406
404
|
|