bonsoir 0.1.1 copy "bonsoir: ^0.1.1" to clipboard
bonsoir: ^0.1.1 copied to clipboard

outdated

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.

Bonsoir is a Zeroconf library that allows you to discover network services and to broadcast your own. It's based on Android NSD and on Apple's popular framework Bonjour. In fact, Bonsoir can be translated to Good evening (and Bonjour to Good morning or Good afternoon).

Preview #

Bonsoir preview

Code snippets #

Here is how you can broadcast your service using Bonsoir :

// Let's create our service !
BonsoirService service = BonsoirService(
  name: 'My wonderful service', // Put your service name here.
  type: '_wonderful-service._tcp', // Put your service type here. Syntax : _ServiceType._TransportProtocolName. (see http://wiki.ros.org/zeroconf/Tutorials/Understanding%20Zeroconf%20Service%20Types).
  port: 3030, // Put your service port here.
);

// And now we can broadcast it :
BonsoirBroadcast broadcast = BonsoirBroadcast(service: service);
await broadcast.ready;
await broadcast.start();

// ...

// Then if you want to stop the broadcast :
await broadcast.stop();

And here is how you can broadcast your service :

// This is the type of service we're looking for :
String type = '_wonderful-service._tcp';

// Once defined, we can start the discovery :
BonsoirDiscovery discovery = BonsoirDiscovery(type: type);
await discovery.ready;
await discovery.start();

// If you want to listen to the discovery :
discovery.eventStream.listen((event) {
  if (event.type == BonsoirDiscoveryEventType.DISCOVERY_SERVICE_FOUND) {
    print('Service found : ${event.service.toJson()}')
  } else if (event.type == BonsoirDiscoveryEventType.DISCOVERY_SERVICE_LOST) {
    print('Service lost : ${event.service.toJson()}')
  }
});

// Then if you want to stop the discovery :
await discovery.stop();

If you want a full example, don't hesitate to check this one on Github.

Final notes #

This plugin cannot be tested on an Android emulator (well it can, but the only services that you are able to discover are the ones broadcasted by your emulator).

The hand icon has been created by Vitaly Gorbachev.

Contributions #

You have a lot of options to contribute to this project ! You can :

91
likes
0
pub points
93%
popularity

Publisher

verified publisherskyost.eu

A Zeroconf library that allows you to discover network services and to broadcast your own. Based on Apple Bonjour and Android NSD.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on bonsoir