Skip to content

Commit

Permalink
local ports now need to be reset
Browse files Browse the repository at this point in the history
  • Loading branch information
Levi-Lesches committed Jan 22, 2024
1 parent 9862f7c commit 23c8187
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/src/models/data/sockets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ class Sockets extends Model {
data.destination = settings.subsystemsSocket.copyWith(address: addressOverride);
video.destination = settings.videoSocket.copyWith(address: addressOverride);
autonomy.destination = settings.autonomySocket.copyWith(address: addressOverride);
await reset();
}

/// Resets all the sockets.
Expand All @@ -101,20 +100,19 @@ class Sockets extends Model {
/// Resetting the sockets will bypass these errors.
Future<void> reset() async {
for (final socket in sockets) {
// Sockets lose their destination when disposed, so we save it and restore it.
final destination = socket.destination;
await socket.dispose();
socket.destination = destination;
await socket.init();
}
// Sockets lose their destination when disposed, so we restore it.
await updateSockets();
}

/// Change which rover is being used.
Future<void> setRover(RoverType? value) async {
if (value == null) return;
rover = value;
models.home.setMessage(severity: Severity.info, text: "Using: ${rover.name}");
await updateSockets();
await reset();
notifyListeners();
}
}

0 comments on commit 23c8187

Please sign in to comment.