我正在尝试每隔 5 秒运行一次“checkServer”。但是“服务器很好”只运行一次。重复该功能需要做什么?
import 'dart:io';
import 'dart:uri';
import 'dart:isolate';
checkServer() {
HttpClient client = new HttpClient();
HttpClientConnection connection = client.getUrl(...);
connection.onResponse = (res) {
...
print('server is fine');
//client.shutdown();
};
connection.onError = ...;
}
main() {
new Timer.repeating(5000, checkServer());
}