Nimrodda / flutter_nsd

A Flutter plugin that enables Network Service Discovery (mDNS) on various platforms via their native APIs.
Apache License 2.0
34 stars 8 forks source link

Stream<NsdServiceInfo> doesn't add service If msdn server hass service txt is added #38

Closed casterock closed 2 years ago

casterock commented 2 years ago

I'm working with flutter_nsd example and an ESP8266. If I configure my ESP without service txt the example discovers him, but when I add a service txt the example couldn't discover him. My router has service txt too and can't be discovered by the example. I think is a Stream declaration problem

My ESP hostname is "lucho", here a print of the stream: I added a service txt called "endpoint" "/stream"

Pay atention to line: 192.168.0.57:5353 : additional lucho._http._tcp.local. TXT endpoint = /stream last record in this packet imagen

I can see the broadcast but service not added

Thanks

Nimrodda commented 2 years ago

I see you're testing on Windows. Is it so? We had an issue with TXT field on Windows which was fixed, but wasn't released until now. Could you please try with latest version 1.3.3 and see if it fixes your issue?

casterock commented 2 years ago

Thanks, updated and now is working but seams that Strings are converted to Char, take a look i'm using this line to show text: title: Text( (services[index].name.toString() +services[index].txt.toString() +services[index].hostname.toString() ) ?? 'Invalid service name'),

imagen

Thanks and best regards

Nimrodda commented 2 years ago

Can you try with other platforms? I'd like to know if it's specific to Windows.

casterock commented 2 years ago

Same in Android. Thanks for the support

Nimrodda commented 2 years ago

OK, now I know what happened. This is intended behavior. If you check txt's type definition, you'll see it is: final Map<String, Uint8List>? txt;. It is implemented this way because TXT record can also be non-String value. If for example in your case it is a UTF8 encoded string, you should decode it like utf8.decode(serviceInfo.txt!['foo']!). utf is provided by Dart's convert library.