Use better way to initialize task manager listener and timers

This commit is contained in:
2024-05-26 07:42:26 +08:00
parent a6d0a2e3c7
commit dc744a9154
3 changed files with 4 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ class TaskManager {
List<int> peddingGids = [];
List<String> peddingTokens = [];
late Timer _pingTimer;
bool _inited = false;
bool get inited => _inited;
void clear() {
tasks.clear();
_channel?.stream.drain();
@@ -233,6 +235,7 @@ class TaskManager {
}
void init() {
_inited = true;
listener.on("lifecycle", _onLifeCycleChanged);
_pingTimer = Timer.periodic(const Duration(seconds: 30), (timer) {
try {