feat(android): stream the connection info
This commit is contained in:
@@ -126,6 +126,14 @@ class NearbyAndroidService extends NearbyService {
|
||||
return NearbyServiceAndroidPlatform.instance.getConnectionInfo();
|
||||
}
|
||||
|
||||
///
|
||||
/// Streams [NearbyConnectionAndroidInfo] -
|
||||
/// information about the connection information.
|
||||
///
|
||||
Stream<NearbyConnectionAndroidInfo?> getConnectionInfoStream() {
|
||||
return NearbyServiceAndroidPlatform.instance.getConnectionInfoStream();
|
||||
}
|
||||
|
||||
void _requireAndroidDevice(NearbyDevice device) {
|
||||
assert(
|
||||
device is NearbyAndroidDevice,
|
||||
|
||||
@@ -54,4 +54,10 @@ abstract class NearbyServiceAndroidPlatform extends PlatformInterface {
|
||||
Future<bool> disconnect(String deviceAddress) {
|
||||
throw UnimplementedError('disconnect() has not been implemented.');
|
||||
}
|
||||
|
||||
Stream<NearbyConnectionAndroidInfo?> getConnectionInfoStream() {
|
||||
throw UnimplementedError(
|
||||
'getConnectionInfoStream() has not been implemented.',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,4 +64,14 @@ class MethodChannelAndroidNearbyService extends NearbyServiceAndroidPlatform {
|
||||
)) ??
|
||||
false;
|
||||
}
|
||||
|
||||
@override
|
||||
Stream<NearbyConnectionAndroidInfo?> getConnectionInfoStream() {
|
||||
const connectedDeviceChannel = EventChannel(
|
||||
"nearby_service_connection_info",
|
||||
);
|
||||
return connectedDeviceChannel.receiveBroadcastStream().map(
|
||||
(e) => NearbyConnectionInfoMapper.mapToInfo(e),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ class FilesSocket {
|
||||
final NearbyMessageFilesContent content;
|
||||
final void Function(String) onDestroy;
|
||||
final NearbyServiceFilesListener? listener;
|
||||
|
||||
final WebSocket _socket;
|
||||
|
||||
final _files = <NearbyFile>[];
|
||||
final _bytesTable = <String, List<int>>{'0': []};
|
||||
final _futures = <Future>[];
|
||||
|
||||
Reference in New Issue
Block a user