[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:
@@ -69,6 +69,16 @@ class NearbyAndroidService extends NearbyService {
|
||||
return NearbyServiceAndroidPlatform.instance.disconnect();
|
||||
}
|
||||
|
||||
///
|
||||
/// On [NearbyServiceBusyException] you can check for running jobs
|
||||
/// (if any of devices has [NearbyDeviceStatus.connecting]).
|
||||
///
|
||||
/// If so, call [cancelLastConnectionProcess] to cancel last request
|
||||
///
|
||||
Future<bool> cancelLastConnectionProcess() {
|
||||
return NearbyServiceAndroidPlatform.instance.cancelConnect();
|
||||
}
|
||||
|
||||
///
|
||||
/// Starts a socket service to transfer data. Uses device with
|
||||
/// [NearbyCommunicationChannelData.connectedDeviceId].
|
||||
|
||||
@@ -55,6 +55,10 @@ abstract class NearbyServiceAndroidPlatform extends PlatformInterface {
|
||||
throw UnimplementedError('disconnect() has not been implemented.');
|
||||
}
|
||||
|
||||
Future<bool> cancelConnect() {
|
||||
throw UnimplementedError('cancelConnect() has not been implemented.');
|
||||
}
|
||||
|
||||
Stream<NearbyConnectionAndroidInfo?> getConnectionInfoStream() {
|
||||
throw UnimplementedError(
|
||||
'getConnectionInfoStream() has not been implemented.',
|
||||
|
||||
@@ -66,6 +66,12 @@ class MethodChannelAndroidNearbyService extends NearbyServiceAndroidPlatform {
|
||||
return _handleBooleanResult(result);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> cancelConnect() async {
|
||||
final result = await methodChannel.invokeMethod("cancelConnect");
|
||||
return _handleBooleanResult(result);
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<NearbyConnectionAndroidInfo?> getConnectionInfoStream() {
|
||||
const connectedDeviceChannel = EventChannel(
|
||||
|
||||
Reference in New Issue
Block a user