Skip to content

AndersonYangOh/RxDNSSD

 
 

Repository files navigation

#RxDNSSD Circle CI

Android library which is Rx wrapper for Apple DNSSD Java API.

##Why RxDNSSD? My explanation about why jmDNS, Android NSD Services and Google Nearby API are not good enough, and why I maintain this library.

##Binaries

compile 'com.github.andriydruk:rxdnssd:0.8.1'

##How to use

RxDNSSD provides two implementations of RxDnssd interface:

  • RxDnssdBindable
  • RxDnssdEmbedded

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).

RxDnssd rxdnssd = new RxDnssdBindable(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.

RxDnssd rxdnssd = new RxDnssdEmbedded(); 

#####Register service

Subscription subscription = rxdnssd.register(bonjourService)
      .observeOn(AndroidSchedulers.mainThread())
      .subscribe(service -> {
      		updateUi();
      }, throwable -> {
        	Log.e("DNSSD", "Error: ", throwable);
      });

#####Browse services example

Subscription subscription = rxDnssd.browse("_http._tcp", "local.")
	.compose(rxDnssd.resolve())
    .compose(rxDnssd.queryRecords())
    .subscribeOn(Schedulers.io())
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe(new Action1<BonjourService>() {
    	@Override
        public void call(BonjourService bonjourService) {
        	Log.d("TAG", bonjourService.toString());
        }
    }, new Action1<Throwable>() {
        @Override
        public void call(Throwable throwable) {
        	Log.e("TAG", "error", throwable);
        }
	});

License

Copyright (C) 2016 Andriy Druk

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Reactive version of DNSSD for Android

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 89.7%
  • Java 7.6%
  • Makefile 1.1%
  • Roff 1.1%
  • Other 0.5%