[Android] Add cancel request method (#7)

* feat: add cancel connect for android

* fix: cancel connect only for android

* fix: clean up the project

* chore: new fvm version

* chore: code style and comments

* chore: bump version to 0.0.8
This commit is contained in:
Kseniia Nikitina
2024-05-18 12:34:05 +02:00
committed by GitHub
parent e4a8c2243f
commit 906e87c6a9
11 changed files with 72 additions and 7 deletions
+15
View File
@@ -135,6 +135,10 @@ class AppService extends ChangeNotifier {
Future<void> stopDiscovery() async {
try {
final hasRunning = await hasRunningJobs();
if (hasRunning) {
await cancelConnect();
}
final result = await _nearbyService.stopDiscovery();
if (result) {
updateState(AppState.readyToDiscover);
@@ -170,6 +174,17 @@ class AppService extends ChangeNotifier {
notifyListeners();
}
Future<void> cancelConnect() async {
try {
await _nearbyService.android?.cancelLastConnectionProcess();
} on NearbyServiceBusyException catch (_) {
_logBusyException();
} catch (e, s) {
_log(e, s);
}
notifyListeners();
}
Future<void> stopListeningAll() async {
await endCommunicationChannel();
await stopListeningConnectedDevice();