From d32f2dec9872e1243e4816f967d928c9d7e6dc5d Mon Sep 17 00:00:00 2001 From: Andriy Druk Date: Mon, 14 Aug 2017 13:08:21 +0300 Subject: [PATCH] Docs: update documentation for 0.9.0 version --- README.md | 155 ++++++++++++++++-- .../druk/dnssdsamples/DNSSDActivity.java | 2 +- rxdnssd/build.gradle | 6 +- .../java/com/github/druk/rxdnssd/RxDnssd.java | 2 + 4 files changed, 147 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 81ed6d6..aacb35c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,79 @@ -# RxDNSSD [![Circle CI](https://circleci.com/gh/andriydruk/RxDNSSD.svg?style=shield&circle-token=5f0cb1ee907a20bdb08aa4b073b5690afbaaabe1)](https://circleci.com/gh/andriydruk/RxDNSSD) +# Android mDNSResponder [![Circle CI](https://circleci.com/gh/andriydruk/RxDNSSD.svg?style=shield&circle-token=5f0cb1ee907a20bdb08aa4b073b5690afbaaabe1)](https://circleci.com/gh/andriydruk/RxDNSSD) [![Download](https://api.bintray.com/packages/andriydruk/maven/dnssd/images/download.svg)](https://bintray.com/andriydruk/maven/rxdnssd/_latestVersion) [![Download](https://api.bintray.com/packages/andriydruk/maven/rxdnssd/images/download.svg)](https://bintray.com/andriydruk/maven/rxdnssd/_latestVersion) -Android library which is Rx wrapper for Apple DNSSD Java API. -## Why RxDNSSD? + +## Why I created this library? My [explanation](http://andriydruk.com/post/mdnsresponder/) about why jmDNS, Android NSD Services and Google Nearby API are not good enough, and why I maintain this library. +## Hierarchy + +There are two version of mDNSReposder. + +Bindable version: + +``` + +--------------------+ +--------------------+ + | RxDNSSD | | RxDNSSD2 | + +--------------------+ +--------------------+ + | | + | +--------------------+ | + -->| Android Java DNSSD |<-- + +--------------------+ + | Apple Java DNSSD | + +------------------+ +--------------------+ + | daemon.c |<-------->| mDNS Client | + +------------------+ +--------------------+ + | mDNS Core | + +------------------+ + | Platform Support | + +------------------+ + System process Your Android app + +``` + +Embedded version: + +``` + +--------------------+ +--------------------+ + | RxDNSSD | | RxDNSSD2 | + +--------------------+ +--------------------+ + | | + | +--------------------+ | + -->| Android Java DNSSD |<-- + +--------------------+ + | Apple Java DNSSD | + +--------------------+ + | mDNS Client | + +--------------------+ + | Embedded mDNS Core | + +--------------------+ + | Platform Support | + +--------------------+ + Your Android app + +``` + ## Binaries + +My dnssd library: + ```groovy -compile 'com.github.andriydruk:rxdnssd:0.8.4' +compile 'com.github.andriydruk:dnssd:0.9.0' ``` -* It's built with Andorid NDK r13b for all platforms (2.18 MB). If you prefer another NDK version or subset of platforms, please build it from source with command: + +My rxdnssd library: + +```groovy +compile 'com.github.andriydruk:rxdnssd:0.9.0' +``` + +My rxdnssd2 library: + +``` +Still in progress ... +``` + +* It's built with Andorid NDK r14b for all platforms (2.18 MB). If you prefer another NDK version or subset of platforms, please build it from source with command: ```groovy ./gradlew clean build @@ -17,20 +81,83 @@ compile 'com.github.andriydruk:rxdnssd:0.8.4' ## How to use -RxDNSSD provides two implementations of RxDnssd interface: +### DNSSD -- RxDnssdBindable -- RxDnssdEmbedded +Dnssd library provides two implementations of DNSSD interface: -RxDnssdBindable is an implementation of RxDnssd with system's daemon. Use it for Android project with min API higher than 4.1 for an economy of battery consumption (Also some Samsung devices can don't work with this implementation). +DNSSDBindable is an implementation of DNSSD with system's daemon. Use it for Android project with min API higher than 4.1 for an economy of battery consumption (Also some Samsung devices can don't work with this implementation). -```java -RxDnssd rxdnssd = new RxDnssdBindable(context); +``` +DNSSD dnssd = new DNSSDBindable(context); ``` -RxDnssdEmbedded is an implementation of RxDnssd with embedded DNS-SD core. Can be used for any Android device with min API higher than Android 4.0. +DNSSDEmbedded is an implementation of RxDnssd with embedded DNS-SD core. Can be used for any Android device with min API higher than Android 4.0. +``` +DNSSD dnssd = new DNSSDEmbedded(); +``` + +##### Register service ```java +try { + registerService = dnssd.register("service_name", "_rxdnssd._tcp", 123, + new RegisterListener() { + + @Override + public void serviceRegistered(DNSSDRegistration registration, int flags, + String serviceName, String regType, String domain) { + Log.i("TAG", "Register successfully "); + } + + @Override + public void operationFailed(DNSSDService service, int errorCode) { + Log.e("TAG", "error " + errorCode); + } + }); +} catch (DNSSDException e) { + Log.e("TAG", "error", e); +} +``` + +##### Browse services example +```java +try { + browseService = dnssd.browse("_rxdnssd._tcp", new BrowseListener() { + + @Override + public void serviceFound(DNSSDService browser, int flags, int ifIndex, + final String serviceName, String regType, String domain) { + Log.i("TAG", "Found " + serviceName); + } + + @Override + public void serviceLost(DNSSDService browser, int flags, int ifIndex, + String serviceName, String regType, String domain) { + Log.i("TAG", "Lost " + serviceName); + } + + @Override + public void operationFailed(DNSSDService service, int errorCode) { + Log.e("TAG", "error: " + errorCode); + } + }); +} catch (DNSSDException e) { + Log.e("TAG", "error", e); +} +``` + +You can find more samples in app inside this repository. + +### RxDNSSD + +RxDNSSD also provides two implementations of RxDnssd interface: + +- RxDnssdBindable +``` +RxDnssd rxdnssd = new RxDnssdBindable(context); +``` +- RxDnssdEmbedded +``` RxDnssd rxdnssd = new RxDnssdEmbedded(); ``` @@ -65,6 +192,10 @@ Subscription subscription = rxDnssd.browse("_http._tcp", "local.") }); ``` +### RxDNSSD2 + +Still in progress ... (I recieve PR 😉) + License ------- Copyright (C) 2016 Andriy Druk diff --git a/app/src/main/java/com/github/druk/dnssdsamples/DNSSDActivity.java b/app/src/main/java/com/github/druk/dnssdsamples/DNSSDActivity.java index 1168e9a..db4bcca 100644 --- a/app/src/main/java/com/github/druk/dnssdsamples/DNSSDActivity.java +++ b/app/src/main/java/com/github/druk/dnssdsamples/DNSSDActivity.java @@ -86,7 +86,7 @@ public void onClick(View v) { }; - RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); + RecyclerView recyclerView = findViewById(R.id.recycler_view); recyclerView.setLayoutManager(new LinearLayoutManager(this)); recyclerView.setAdapter(mServiceAdapter); } diff --git a/rxdnssd/build.gradle b/rxdnssd/build.gradle index d1c8b65..fc2a3f2 100644 --- a/rxdnssd/build.gradle +++ b/rxdnssd/build.gradle @@ -1,10 +1,6 @@ apply plugin: 'com.android.library' apply plugin: 'com.novoda.bintray-release' -repositories { - mavenCentral() -} - android { compileSdkVersion 26 buildToolsVersion "26.0.1" @@ -29,7 +25,7 @@ android { } dependencies { - compile project(':library') + compile 'com.github.andriydruk:dnssd:0.9.0' compile 'io.reactivex:rxandroid:1.2.1' compile 'io.reactivex:rxjava:1.3.0' diff --git a/rxdnssd/src/main/java/com/github/druk/rxdnssd/RxDnssd.java b/rxdnssd/src/main/java/com/github/druk/rxdnssd/RxDnssd.java index e26a803..233cd6d 100644 --- a/rxdnssd/src/main/java/com/github/druk/rxdnssd/RxDnssd.java +++ b/rxdnssd/src/main/java/com/github/druk/rxdnssd/RxDnssd.java @@ -17,6 +17,8 @@ import android.support.annotation.NonNull; +import com.github.druk.dnssd.DNSSD; + import rx.Observable; /**