替换dowhile实现方式
This commit is contained in:
@@ -51,12 +51,12 @@ class Redis {
|
||||
_connected = true;
|
||||
//定时检测是否断开连接
|
||||
Future.delayed(Duration(seconds: 1), () async {
|
||||
do {
|
||||
await Future.doWhile(() async {
|
||||
await Future.delayed(Duration(seconds: 5));
|
||||
try {
|
||||
var r = await _command!.send_object(["PING"]);
|
||||
if (r != "PONG") {
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
//发送数据失败
|
||||
@@ -66,9 +66,28 @@ class Redis {
|
||||
} catch (o) {
|
||||
//
|
||||
}
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
} while (true);
|
||||
return true;
|
||||
});
|
||||
// do {
|
||||
// await Future.delayed(Duration(seconds: 5));
|
||||
// try {
|
||||
// var r = await _command!.send_object(["PING"]);
|
||||
// if (r != "PONG") {
|
||||
// break;
|
||||
// }
|
||||
// } catch (e) {
|
||||
// //发送数据失败
|
||||
// try {
|
||||
// print('Redis Connection check failed: $e');
|
||||
// _command!.get_connection().close();
|
||||
// } catch (o) {
|
||||
// //
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// } while (true);
|
||||
connect(reconnect: true);
|
||||
});
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user