@netless/window-manager 0.4.30-canary.0 → 0.4.30-canary.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/dist/constants.d.ts +1 -0
- package/dist/index.cjs.js +12 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +20 -5
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/App/AppProxy.ts +5 -0
- package/src/ReconnectRefresher.ts +18 -4
- package/src/constants.ts +1 -0
package/package.json
CHANGED
package/src/App/AppProxy.ts
CHANGED
@@ -241,6 +241,11 @@ export class AppProxy implements PageRemoveService {
|
|
241
241
|
}
|
242
242
|
|
243
243
|
public async onReconnected() {
|
244
|
+
const isExist = Boolean(this.manager.attributes.apps[this.id]);
|
245
|
+
if (!isExist) {
|
246
|
+
await this.destroy(true, false, true);
|
247
|
+
return;
|
248
|
+
}
|
244
249
|
this.appEmitter.emit("reconnected", undefined);
|
245
250
|
const currentAppState = this.getAppInitState(this.id);
|
246
251
|
await this.destroy(true, false, true);
|
@@ -3,6 +3,7 @@ import { log } from "./Utils/log";
|
|
3
3
|
import { RoomPhase } from "white-web-sdk";
|
4
4
|
import type { Room } from "white-web-sdk";
|
5
5
|
import type { EmitterType } from "./InternalEmitter";
|
6
|
+
import { EnsureReconnectEvent } from "./constants";
|
6
7
|
|
7
8
|
export type ReconnectRefresherContext = {
|
8
9
|
emitter: EmitterType;
|
@@ -20,8 +21,20 @@ export class ReconnectRefresher {
|
|
20
21
|
public setRoom(room: Room | undefined) {
|
21
22
|
this.room = room;
|
22
23
|
this.phase = room?.phase;
|
23
|
-
room
|
24
|
-
|
24
|
+
if (room) {
|
25
|
+
room.callbacks.off("onPhaseChanged", this.onPhaseChanged);
|
26
|
+
room.callbacks.on("onPhaseChanged", this.onPhaseChanged);
|
27
|
+
// 重连成功之后向服务发送一次消息, 确认当前的状态是最新的
|
28
|
+
room.addMagixEventListener(
|
29
|
+
EnsureReconnectEvent,
|
30
|
+
payload => {
|
31
|
+
if (payload.authorId === room.observerId) {
|
32
|
+
this.onReconnected();
|
33
|
+
}
|
34
|
+
},
|
35
|
+
{ fireSelfEventAfterCommit: true }
|
36
|
+
);
|
37
|
+
}
|
25
38
|
}
|
26
39
|
|
27
40
|
public setContext(ctx: ReconnectRefresherContext) {
|
@@ -33,7 +46,7 @@ export class ReconnectRefresher {
|
|
33
46
|
this.ctx.emitter.emit("startReconnect");
|
34
47
|
}
|
35
48
|
if (phase === RoomPhase.Connected && this.phase === RoomPhase.Reconnecting) {
|
36
|
-
this.
|
49
|
+
this.room?.dispatchMagixEvent(EnsureReconnectEvent, {});
|
37
50
|
}
|
38
51
|
this.phase = phase;
|
39
52
|
};
|
@@ -51,7 +64,7 @@ export class ReconnectRefresher {
|
|
51
64
|
}
|
52
65
|
});
|
53
66
|
this.ctx.emitter.emit("onReconnected");
|
54
|
-
}
|
67
|
+
};
|
55
68
|
|
56
69
|
private releaseDisposers() {
|
57
70
|
this.disposers.forEach(disposer => {
|
@@ -96,6 +109,7 @@ export class ReconnectRefresher {
|
|
96
109
|
|
97
110
|
public destroy() {
|
98
111
|
this.room?.callbacks.off("onPhaseChanged", this.onPhaseChanged);
|
112
|
+
this.room?.removeMagixEventListener(EnsureReconnectEvent, this.onReconnected);
|
99
113
|
this.releaseDisposers();
|
100
114
|
}
|
101
115
|
}
|