new: custom timeout

This commit is contained in:
lollipopkit
2023-08-30 19:07:32 +08:00
parent c899a84b29
commit f4b6326652
4 changed files with 23 additions and 4 deletions

View File

@@ -198,7 +198,10 @@ class ServerProvider extends ChangeNotifier {
// Only reconnect if neccessary
if (newSpi.shouldReconnect(old)) {
_servers[newSpi.id]?.client = await genClient(newSpi);
_servers[newSpi.id]?.client = await genClient(
newSpi,
timeout: _settingStore.timeoutD,
);
refreshData(spi: newSpi);
}
@@ -231,7 +234,10 @@ class ServerProvider extends ChangeNotifier {
final time1 = DateTime.now();
try {
s.client = await genClient(spi);
s.client = await genClient(
spi,
timeout: _settingStore.timeoutD,
);
} catch (e) {
_limiter.inc(sid);
s.status.failedInfo = e.toString();

View File

@@ -153,4 +153,14 @@ class SettingStore extends PersistentStore {
'serverTabUseOldUI',
false,
);
/// Time out for server connect and more...
late final timeout = StoreProperty(
box,
'timeOut',
5,
);
/// Duration of [timeout]
Duration get timeoutD => Duration(seconds: timeout.fetch());
}