@shimotsuki/core 2.0.37 → 2.0.39
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/index.d.ts +1 -0
- package/dist/index.js +16 -12
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -785,6 +785,7 @@ declare class SocialGameClientManager extends BaseManager {
|
|
|
785
785
|
private isInBackground;
|
|
786
786
|
readonly onEventHideDelegate: AsyncDelegate<() => (Promise<void> | void)>;
|
|
787
787
|
readonly onEventShowDelegate: AsyncDelegate<() => (Promise<void> | void)>;
|
|
788
|
+
readonly onEventReloadSceneDelegate: AsyncDelegate<() => (Promise<void> | void)>;
|
|
788
789
|
get activeClients(): WrapperSocialGameClient[];
|
|
789
790
|
constructor(cat: Manager);
|
|
790
791
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2350,6 +2350,7 @@ class SocialGameClientManager extends BaseManager {
|
|
|
2350
2350
|
isInBackground = false;
|
|
2351
2351
|
onEventHideDelegate = new AsyncDelegate();
|
|
2352
2352
|
onEventShowDelegate = new AsyncDelegate();
|
|
2353
|
+
onEventReloadSceneDelegate = new AsyncDelegate();
|
|
2353
2354
|
get activeClients() {
|
|
2354
2355
|
return Array.from(this.managedClients)
|
|
2355
2356
|
.map(([_, client]) => client)
|
|
@@ -2420,10 +2421,10 @@ class SocialGameClientManager extends BaseManager {
|
|
|
2420
2421
|
case 'show':
|
|
2421
2422
|
this.isInBackground = false;
|
|
2422
2423
|
await this.triggerReconnectAll();
|
|
2423
|
-
await this.
|
|
2424
|
+
await this.onEventShowDelegate.dispatch();
|
|
2424
2425
|
break;
|
|
2425
2426
|
case 'hide':
|
|
2426
|
-
await this.
|
|
2427
|
+
await this.onEventHideDelegate.dispatch();
|
|
2427
2428
|
this.isInBackground = true;
|
|
2428
2429
|
this.disconnectAll(true);
|
|
2429
2430
|
break;
|
|
@@ -2449,15 +2450,6 @@ class SocialGameClientManager extends BaseManager {
|
|
|
2449
2450
|
cat.gui.showToast({ title: `${client.name}服重连失败` });
|
|
2450
2451
|
// 不抛出错误,让 Promise.allSettled 收集结果
|
|
2451
2452
|
}
|
|
2452
|
-
try {
|
|
2453
|
-
// 2. 执行业务层连接请求
|
|
2454
|
-
await client.connectRequest();
|
|
2455
|
-
}
|
|
2456
|
-
catch (err) {
|
|
2457
|
-
error(`${client.name}服登录错误`, err);
|
|
2458
|
-
cat.gui.showToast({ title: `登录${client.name}服错误` });
|
|
2459
|
-
// 同样不抛出错误
|
|
2460
|
-
}
|
|
2461
2453
|
}));
|
|
2462
2454
|
// 检查是否有客户端未成功连接
|
|
2463
2455
|
const failedClients = this.activeClients.filter(client => client.socketConnectStatus !== SocketConnectStatus.CONNECTED);
|
|
@@ -2477,9 +2469,21 @@ class SocialGameClientManager extends BaseManager {
|
|
|
2477
2469
|
});
|
|
2478
2470
|
}
|
|
2479
2471
|
// 单个WS重连成功回调
|
|
2480
|
-
handleSingleReconnect = () => {
|
|
2472
|
+
handleSingleReconnect = async () => {
|
|
2481
2473
|
if (this.activeClients.every(client => client.socketConnectStatus === SocketConnectStatus.CONNECTED)) {
|
|
2482
2474
|
log('单个WS重连成功回调===', this.managedClients);
|
|
2475
|
+
await Promise.allSettled(this.activeClients.map(async (client) => {
|
|
2476
|
+
// 连接社交游戏服务
|
|
2477
|
+
try {
|
|
2478
|
+
// 2. 执行业务层连接请求
|
|
2479
|
+
await client.connectRequest();
|
|
2480
|
+
}
|
|
2481
|
+
catch (err) {
|
|
2482
|
+
error(`${client.name}服登录错误`, err);
|
|
2483
|
+
cat.gui.showToast({ title: `登录${client.name}服错误` });
|
|
2484
|
+
}
|
|
2485
|
+
}));
|
|
2486
|
+
await this.onEventReloadSceneDelegate.dispatch();
|
|
2483
2487
|
cat.gui.hideLoading().reloadScene();
|
|
2484
2488
|
}
|
|
2485
2489
|
};
|