diff --git a/lib/services/nt4.dart b/lib/services/nt4.dart index e477bd65..3454da6d 100644 --- a/lib/services/nt4.dart +++ b/lib/services/nt4.dart @@ -302,7 +302,14 @@ class NT4Client { // Prevents repeated calls to onConnect and reconnecting after changing ip addresses if (!_serverConnectionActive && serverAddr.contains(serverBaseAddress)) { + lastAnnouncedValues.clear(); + + for (NT4Subscription sub in _subscriptions.values) { + sub.currentValue = null; + } + _serverConnectionActive = true; + onConnect?.call(); } _wsOnMessage(data); @@ -345,12 +352,6 @@ class NT4Client { announcedTopics.clear(); - lastAnnouncedValues.clear(); - - for (NT4Subscription sub in _subscriptions.values) { - sub.currentValue = null; - } - if (kDebugMode) { print('[NT4] Connection closed. Attempting to reconnect in 1s'); } diff --git a/lib/widgets/nt4_widgets/multi-topic/camera_stream.dart b/lib/widgets/nt4_widgets/multi-topic/camera_stream.dart index 344a80b1..146b4cc7 100644 --- a/lib/widgets/nt4_widgets/multi-topic/camera_stream.dart +++ b/lib/widgets/nt4_widgets/multi-topic/camera_stream.dart @@ -121,7 +121,7 @@ class CameraStreamWidget extends StatelessWidget with NT4Widget { streams.add(stream.substring(5)); } - if (streams.isEmpty) { + if (streams.isEmpty || !nt4Connection.isNT4Connected) { return Stack( fit: StackFit.expand, children: [