homey-api 3.17.9 → 3.17.10
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.
|
@@ -77,6 +77,29 @@ class SubscriptionRegistry {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
async ensureSessionSubscriptions({ revision, homeySocket, isReconnect }) {
|
|
81
|
+
if (!isReconnect) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const reconnectPromises = [];
|
|
86
|
+
|
|
87
|
+
for (const entry of this.__entries.values()) {
|
|
88
|
+
if (entry.consumers.size === 0) {
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!entry.needsReconnect && entry.subscribedRevision === revision) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
this.__bindEventSocket(entry, homeySocket);
|
|
97
|
+
reconnectPromises.push(this.__resumeEntry(entry, revision));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
await Promise.all(reconnectPromises);
|
|
101
|
+
}
|
|
102
|
+
|
|
80
103
|
destroy() {
|
|
81
104
|
if (this.__destroyed) return;
|
|
82
105
|
|
|
@@ -232,21 +255,10 @@ class SubscriptionRegistry {
|
|
|
232
255
|
}
|
|
233
256
|
|
|
234
257
|
__onSessionReady({ revision, homeySocket, isReconnect }) {
|
|
235
|
-
if (!isReconnect) {
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
258
|
// The transport can reconnect before the current Homey namespace is ready.
|
|
240
259
|
// Listen to both reconnect and ready so entries resume promptly, while
|
|
241
260
|
// ready is the point where the active namespace socket can be rebound.
|
|
242
|
-
|
|
243
|
-
if (entry.consumers.size === 0 || !entry.needsReconnect) {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
this.__bindEventSocket(entry, homeySocket);
|
|
248
|
-
this.__resumeEntry(entry, revision);
|
|
249
|
-
}
|
|
261
|
+
this.ensureSessionSubscriptions({ revision, homeySocket, isReconnect }).catch(() => {});
|
|
250
262
|
}
|
|
251
263
|
|
|
252
264
|
__onSessionReconnect() {
|
|
@@ -529,7 +529,8 @@ class HomeyAPIV3 extends HomeyAPI {
|
|
|
529
529
|
}
|
|
530
530
|
|
|
531
531
|
async connect() {
|
|
532
|
-
await this.__socketSession.ensureConnected();
|
|
532
|
+
const readyState = await this.__socketSession.ensureConnected();
|
|
533
|
+
await this.__subscriptionRegistry.ensureSessionSubscriptions(readyState);
|
|
533
534
|
}
|
|
534
535
|
|
|
535
536
|
isConnecting() {
|