Closed halfninja closed 6 months ago
Bonjour services are designed to be broadcasted by the current machine. This means that you don't have to specify a custom hostname, because it should be the same than your machine.
This being said, it should be possible to do :
// Create a resolved Bonsoir service instance.
ResolvedBonsoirService service = ResolvedBonsoirService(
// fill the required fields here, including the hostname.
);
// Broadcast it :
BonsoirBroadcast broadcast = BonsoirBroadcast(service: service);
await broadcast.ready;
await broadcast.start();
// ...
// Then if you want to stop the broadcast :
await broadcast.stop();
Hey, thanks for the reply and I totally get the point about Bonjour - it shouldn't matter what the hostname is normally. I'm building an app where the idea is it can be deployed onto a network and be reachable over a simple well-known name, since modern browsers can resolve .local
names. The workaround is of course to change the computer name to the desired name, I'm just trying to make things work out of the box as far as possible.
I gave ResolvedBonsoirService a try and it didn't have an effect, at least on Windows - looking in bonsoir_windows
it looks like it is fixed to always use GetComputerNameEx
.
Thanks again for having a look - I'll either go with the workaround or I might possibly be back with a PR at some point in the future.
I gave ResolvedBonsoirService a try and it didn't have an effect, at least on Windows - looking in
bonsoir_windows
it looks like it is fixed to always useGetComputerNameEx
.
You're right, and it should not happen : we're getting the provided IP address here (as you probably already have seen)... but I forgot to use it later in the code ! Feel free to submit your PR if you think you can fix it 🙂
Fixed in https://github.com/Skyost/Bonsoir/commit/57c8c9a6e8d5412a2f6a62b88583a1150689473d. Feel free to try it @halfninja !
Woah, fast work! I can see the service in a Bonjour service browser under the new hostname - currently still haven't trouble with native web browsers resolving that name but I think Bonsoir is doing its part correctly, and I need to implement broadcast of the actual hostname record that the service record is advertising.
Thanks again, many internet stars to you ⭐⭐⭐
Is your feature request related to a problem? Please describe. I'm trying to make a web server available to any mDNS aware browser on the network via somename.local - currently it only seems to be broadcast on the machine's hostname.local
Describe the solution you'd like The ability to specify a myhostname.local to use
Describe alternatives you've considered I've tried looking at this package and at other packages that try to do a similar thing. I've also looked for any working packages that only do mDNS broadcast, without success.
Additional context It's possible I've misunderstood how everything works so feel free to explain why what I'm asking is bananas. Maybe it's possible in mDNS but not via DNS-SD?