Class BonjourPublisher
java.lang.Object
com.codename1.io.bonjour.BonjourPublisher
Advertises a Bonjour / mDNS service on the local network.
A publisher registers a service of a given type and port; once registered
any client on the same network running BonjourBrowser.browse(type, ...)
will see it. txt records carry small key/value metadata (typical limit
255 bytes per value).
Example -- advertise an HTTP service on port 8080
BonjourPublisher pub = BonjourPublisher.publish(
"MyServer", "_http._tcp.", 8080, null);
// when shutting down
pub.unpublish();
On iOS the build pipeline appends type to NSBonjourServices in
Info.plist automatically when this class is referenced; without that entry
iOS 14+ silently rejects the publish.
-
Method Summary
-
Method Details
-
publish
Publishes a new service.nameis shown to humans browsing services and must be unique on the local subnet; the OS may append a suffix to resolve collisions.typeis the mDNS type (e.g._http._tcp.).portis the listening port on this device.txtmay benullor a String->String map of metadata. -
getName
-
getType
-
getPort
public int getPort() -
unpublish
public void unpublish()Removes the advertisement. Idempotent.
-