Closed guyluz11 closed 3 months ago
Hey,
Thanks for the report. Do you have a snippet or something ?
Hey,
Thanks for the report. Do you have a snippet or something ?
import 'package:bonsoir/bonsoir.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
Future search() async {
String serviceType = '_androidtvremote2._tcp';
try {
BonsoirDiscovery discovery = BonsoirDiscovery(type: serviceType);
await discovery.ready;
Stream<BonsoirDiscoveryEvent>? discoverStream = discovery.eventStream;
if (discoverStream == null) {
return;
}
Future.delayed(const Duration(milliseconds: 1)).then((value) {
discovery.start();
});
Future.delayed(const Duration(seconds: 5)).then((value) {
discovery.stop();
});
await for (BonsoirDiscoveryEvent event in discoverStream) {
if (event.type == BonsoirDiscoveryEventType.discoveryServiceFound) {
event.service?.resolve(discovery.serviceResolver);
print('Found bonsoir ${event.service?.attributes}');
continue;
} else if (event.type ==
BonsoirDiscoveryEventType.discoveryServiceResolved) {
} else {
continue;
}
}
} catch (e) {
print('Error $e');
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Scaffold(
body: Center(
child: TextButton(
onPressed: search,
child: const Text('Search android TV Remote service'),
),
),
),
);
}
}
Did some testing today :
_androidtvremote2._tcp
and _zigate-zigbee-gateway._tcp
are raised because services type should be no more than 15 characters long (https://datatracker.ietf.org/doc/html/rfc6335#section-5.1)._nvstream_dbd
is raised because there is no trailing protocol (._tcp
/ ._udp
).That's being said, it's problematic to have an error when invalid types are being used in BonsoirDiscovery
. I'm gonna convert it to a warning.
I am searching for srv recireds that I found in my home network and online and getting some errors
For example
flutter: Error searching mdns 'package:bonsoir/src/discovery.dart': Failed assertion: line 19 pos 11: 'type == BonsoirServiceNormalizer.normalizeType(type)': The provided type "_androidtvremote2._tcp" is invalid.
Here are srv's that I am getting error for
_androidtvremote2._tcp
_nvstream_dbd
_zigate-zigbee-gateway._tcp
The function it crashes on all of them but for a different reasons https://github.com/Skyost/Bonsoir/blob/de335b602e4caf109eaadf14a001ebbf0f2fed3a/packages/bonsoir_platform_interface/lib/src/service/normalizer.dart#L39
Full list of errors