android rendezvous server status

This commit is contained in:
csf
2022-04-17 11:34:46 +08:00
parent 7177a566ae
commit cabb39005b
3 changed files with 63 additions and 27 deletions

View File

@@ -6,15 +6,17 @@ import '../common.dart';
import '../pages/server_page.dart';
import 'model.dart';
final _emptyIdShow = translate("connecting_status");
final _emptyIdShow = translate("Generating ...");
class ServerModel with ChangeNotifier {
Timer? _interval;
bool _isStart = false;
bool _isStart = false; // Android MainService status
bool _mediaOk = false;
bool _inputOk = false;
bool _audioOk = false;
bool _fileOk = false;
int _connectStatus = 0; // Rendezvous Server status
final _serverId = TextEditingController(text: _emptyIdShow);
final _serverPasswd = TextEditingController(text: "");
@@ -30,6 +32,8 @@ class ServerModel with ChangeNotifier {
bool get fileOk => _fileOk;
int get connectStatus => _connectStatus;
TextEditingController get serverId => _serverId;
TextEditingController get serverPasswd => _serverPasswd;
@@ -80,6 +84,17 @@ class ServerModel with ChangeNotifier {
FFI.setByName('option', jsonEncode(res)); // input false by default
notifyListeners();
}();
Timer.periodic(Duration(seconds: 1), (timer) {
var status = int.tryParse(FFI.getByName('connect_statue')) ?? 0;
if (status > 0) {
status = 1;
}
if (status != _connectStatus) {
_connectStatus = status;
notifyListeners();
}
});
}
toggleAudio() async {