This commit is contained in:
Daniel 2024-10-24 20:00:19 -04:00
parent 9395e8801e
commit f68dd7a1f6
2 changed files with 9 additions and 3 deletions

View file

@ -81,9 +81,11 @@ class Stillbox extends ChangeNotifier {
} }
try { try {
await connect(); await connect();
} on WebSocketChannelException catch(e) { } on WebSocketChannelException catch (e) {
return false; return false;
} }
return true;
} }
return false; return false;
} }
@ -95,7 +97,7 @@ class Stillbox extends ChangeNotifier {
channel.connect(_wsUri); channel.connect(_wsUri);
try { try {
await channel.channel?.ready; await channel.channel?.ready;
} on WebSocketChannelException catch(e) { } on WebSocketChannelException catch (e) {
_handleError(e); _handleError(e);
} }
channel.stream.listen((event) => _handleData(event), channel.stream.listen((event) => _handleData(event),

View file

@ -53,6 +53,7 @@ class _MainRadioState extends State<MainRadio> {
}); });
} }
}); });
sb.callQStream.stream.listen((ctAdd) { sb.callQStream.stream.listen((ctAdd) {
setState(() { setState(() {
queueLen += ctAdd; queueLen += ctAdd;
@ -62,7 +63,7 @@ class _MainRadioState extends State<MainRadio> {
_callLoop(sb); _callLoop(sb);
} }
void _handleSocketError(dynamic error) { void _handleSocketError(Exception error) {
Navigator.pushReplacement( Navigator.pushReplacement(
context, context,
PageRouteBuilder( PageRouteBuilder(
@ -73,6 +74,9 @@ class _MainRadioState extends State<MainRadio> {
transitionDuration: const Duration(milliseconds: 0), transitionDuration: const Duration(milliseconds: 0),
), ),
); );
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(error)),
);
} }
void _callLoop(Stillbox sb) async { void _callLoop(Stillbox sb) async {