This commit is contained in:
Daniel 2024-10-21 21:49:43 -04:00
parent c71ecc1b79
commit 9395e8801e
3 changed files with 21 additions and 4 deletions

View file

@ -1,6 +1,9 @@
import 'dart:async';
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:just_audio/just_audio.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
import '../pb/stillbox.pb.dart';
import 'stillbox_none.dart'
if (dart.library.io) 'stillbox_io.dart'
@ -76,8 +79,11 @@ class Stillbox extends ChangeNotifier {
if (!kIsWeb && token != null) {
storage.setKey('token', token);
}
try {
await connect();
return true;
} on WebSocketChannelException catch(e) {
return false;
}
}
return false;
}
@ -87,6 +93,11 @@ class Stillbox extends ChangeNotifier {
return;
}
channel.connect(_wsUri);
try {
await channel.channel?.ready;
} on WebSocketChannelException catch(e) {
_handleError(e);
}
channel.stream.listen((event) => _handleData(event),
onDone: () {
connected = false;

View file

@ -113,6 +113,11 @@ class _LoginState extends State<Login> {
const Duration(milliseconds: 0),
),
);
} else if (context.mounted) {
// display a snackbar
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('Login failed.')),
);
}
} else {
ScaffoldMessenger.of(context).showSnackBar(

View file

@ -39,7 +39,7 @@ message Call {
}
message Hello {
Version version = 1;
ServerInfo server_info = 1;
}
message UserPopup {
@ -105,9 +105,10 @@ message Filter {
message Search {
}
message Version {
message ServerInfo {
string server_name = 1;
string version = 2;
string built = 3;
string platform = 4;
string db_size = 5;
}