diff --git a/example/lib/main.dart b/example/lib/main.dart index 727482a..3366535 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -201,10 +201,13 @@ class _MyBodyState extends State { ), RaisedButton( child: Text("Reject Connection"), - onPressed: () { + onPressed: () async { Navigator.pop(context); - - Nearby().rejectConnection(id); + try { + await Nearby().rejectConnection(id); + } catch (e) { + showSnackbar(e); + } }, ), ], diff --git a/lib/nearby_connections.dart b/lib/nearby_connections.dart index 14ebfe3..e0f0aaf 100644 --- a/lib/nearby_connections.dart +++ b/lib/nearby_connections.dart @@ -230,7 +230,7 @@ class Nearby { Future rejectConnection(String endpointId) async { return await _channel.invokeMethod( - 'acceptConnection', + 'rejectConnection', { 'endpointId': endpointId, }, @@ -248,18 +248,6 @@ class Nearby { } } -abstract class ConnectionLifecycleCallback { - void onConnectionInitiated(String endpointId, ConnectionInfo connectionInfo); - void onConnectionResult(String endpointId, Status status); - void onDisconnected(String endpointId); -} - -abstract class EndpointDiscoveryCallback { - void onEndpointFound( - String endpointId, String endpointName, String serviceId); - void onEndpointLost(String endpointId); -} - class ConnectionInfo { String endpointName, authenticationToken; bool isIncomingConnection; @@ -267,3 +255,6 @@ class ConnectionInfo { ConnectionInfo( this.endpointName, this.authenticationToken, this.isIncomingConnection); } +//TODO remove errors on failure for smooth experience +//TODO expose only relevant parts as library +//TODO publish to pub.dartlang