Skip to content

Commit

Permalink
JdsServiceStartupOnReconnect | workaround for startup not starting on…
Browse files Browse the repository at this point in the history
… reconnect
  • Loading branch information
Minyewoo committed Mar 30, 2024
1 parent a5ba839 commit ec71ab7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:hmi_networking/src/core/non_repetitive_stream.dart';
///
/// [JdsService] cache update sequence.
class JdsServiceStartupOnReconnect {
static const _log = Log('JdsServiceStartupOnReconnect');
final Stream<DsDataPoint<int>> _connectionStatuses;
final JdsServiceStartup _startup;
bool _isConnected;
Expand Down Expand Up @@ -42,14 +43,18 @@ class JdsServiceStartupOnReconnect {
},
),
).stream
.where((event) => _isStartupCompleted)
.where((_) => _isStartupCompleted)
.listen((_) async {
while(_isConnected) {
_log.info('Entering startup loop...');
_isStartupCompleted = false;
if(await _startup.run() case Ok()) {
_log.info('Startup completed! Exiting startup loop...');
_isStartupCompleted = true;
break;
}
_log.info('Startup failed! Starting next startup attempt...');
_isStartupCompleted = true;
}
});
}
Expand Down

0 comments on commit ec71ab7

Please sign in to comment.