Skip to content

arashpayan/chirp-android

Repository files navigation

Javadoc Latest Maven Central Version

Chirp (Android)

Chirp is a network service discovery protocol. In short, it's a simpler and more reliable alternative to mDNS/Bonjour. For more information about the protocol and libraries for different languages, see the official Chirp homepage.

Installation with Gradle

dependencies {
    compile 'com.arashpayan:chirp:0.2.1'
}

Usage

Listening for services:

String serviceName = "com.example.service"; // use "*" to listen for all services
ChirpBrowser browser = Chirp.browseFor(serviceName).
                             listener(this).
                             start(getApplication());

Publishing a service:

ChirpPublisher publisher = Chirp.publish("com.example.service").
                                 start(getApplication());

You can even include a payload of arbitrary key values (serializable to JSON) to publish with your service:

Map<String, Object> payload = new HashMap<>();
payload.put("port", 1337);
payload.put("serial_number", "thx1138");
ChirpPublisher publisher = Chirp.publish("com.example.service").
                                 payload(payload).
                                 start(getApplication());

When you no longer want your service published:

publisher.stop();

About

Implementation of Chirp protocol for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages