{"id":13575378,"url":"https://github.com/andriydruk/RxDNSSD","last_synced_at":"2025-04-04T22:30:58.690Z","repository":{"id":3591326,"uuid":"50243508","full_name":"andriydruk/RxDNSSD","owner":"andriydruk","description":"Android version of mDNSResponder ","archived":true,"fork":false,"pushed_at":"2022-06-01T16:26:17.000Z","size":1569,"stargazers_count":297,"open_issues_count":37,"forks_count":75,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-11-05T11:42:20.039Z","etag":null,"topics":["android","android-library","bonjour","browse-services","dnssd","dnssd-library","hacktoberfest","mdnsresponder","register-service"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andriydruk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-23T15:10:40.000Z","updated_at":"2024-07-05T06:31:56.000Z","dependencies_parsed_at":"2022-07-14T22:17:05.420Z","dependency_job_id":null,"html_url":"https://github.com/andriydruk/RxDNSSD","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andriydruk%2FRxDNSSD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andriydruk%2FRxDNSSD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andriydruk%2FRxDNSSD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andriydruk%2FRxDNSSD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andriydruk","download_url":"https://codeload.github.com/andriydruk/RxDNSSD/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247260391,"owners_count":20909998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","bonjour","browse-services","dnssd","dnssd-library","hacktoberfest","mdnsresponder","register-service"],"created_at":"2024-08-01T15:01:00.450Z","updated_at":"2025-04-04T22:30:53.679Z","avatar_url":"https://github.com/andriydruk.png","language":"C","funding_links":[],"categories":["C","网络编程"],"sub_categories":["语音合成"],"readme":"\n# THE PROJECT IS ARCHIVED DUE TO THE RUSSIAN INVASION OF UKRAINE\n\n# 🇺🇦 #StandWithUkraine\nOn Feb. 24, 2022 Russia declared an [unprovoked war on Ukraine](https://war.ukraine.ua/russia-war-crimes/) and launched a full-scale invasion. Russia is currently bombing peaceful Ukrainian cities, including schools and hospitals and attacking civilians who are fleeing conflict zones.\n\nPlease support Ukraine by lobbying your governments, protesting peacefully, and donating money to support the people of Ukraine. Below are links to trustworthy organizations that are helping to defend Ukraine in this unprovoked war:\n\n* [Donate to Come Back Alive](https://www.comebackalive.in.ua/donate)\n* [Donate to KOLO](https://koloua.com/en/)\n* [Donate to Prytula Foundation](https://prytulafoundation.org/en)\n\n# Android mDNSResponder [![Circle CI](https://circleci.com/gh/andriydruk/RxDNSSD.svg?style=shield\u0026circle-token=5f0cb1ee907a20bdb08aa4b073b5690afbaaabe1)](https://circleci.com/gh/andriydruk/RxDNSSD) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/dnssd?label=DNSSD)](https://search.maven.org/artifact/com.github.andriydruk/dnssd) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/rxdnssd?label=RxDNSSD)](https://search.maven.org/artifact/com.github.andriydruk/rxdnssd) [![Download](https://img.shields.io/maven-central/v/com.github.andriydruk/rx2dnssd?label=Rx2DNSSD) ](https://search.maven.org/artifact/com.github.andriydruk/rx2dnssd)\n\n\n## Why I created this library?\nMy [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.\n\n## Hierarchy\n\nThere are two version of mDNSReposder. \n\nBindable version:\n\n```\n                                   +--------------------+       +--------------------+\n                                   |      RxDNSSD       |       |       Rx2DNSSD     |\n                                   +--------------------+       +--------------------+\n                                           |                            |\n                                           |   +--------------------+   |\n                                            --\u003e| Android Java DNSSD |\u003c--\n                                               +--------------------+\n                                               |  Apple Java DNSSD  |\n                 +------------------+          +--------------------+\n                 |    daemon.c      |\u003c--------\u003e|     mDNS Client    |\n                 +------------------+          +--------------------+\n                 |    mDNS Core     |\n                 +------------------+\n                 | Platform Support |\n                 +------------------+\n                    System process                Your Android app\n\n```\n\nEmbedded version:\n\n```\n                     +--------------------+       +--------------------+\n                     |      RxDNSSD       |       |       Rx2DNSSD     |\n                     +--------------------+       +--------------------+\n                                |                            |\n                                |   +--------------------+   |\n                                 --\u003e| Android Java DNSSD |\u003c--\n                                    +--------------------+\n                                    |   Apple Java DNSSD |    \n                                    +--------------------+\n                                    |    mDNS Client     |\n                                    +--------------------+\n                                    | Embedded mDNS Core |\n                                    +--------------------+\n                                    | Platform Support   |\n                                    +--------------------+\n                                      Your Android app\n\n```\n\n## Binaries on MavenCentral\n\nDNSSD library:\n\n```groovy\ncompile 'com.github.andriydruk:dnssd:0.9.17'\n```\n\nRxDNSSD library:\n\n```groovy\ncompile 'com.github.andriydruk:rxdnssd:0.9.17'\n```\n\nRx2DNSSD library:\n\n```\ncompile 'com.github.andriydruk:rx2dnssd:0.9.17'\n```\n\n* It's built with Andorid NDK 21 for all platforms (1.7 MB). If you prefer another NDK version or subset of platforms, please build it from source with command:\n\n```groovy\n./gradlew clean build\n```\n\n## How to use\n\n### DNSSD\n\nDnssd library provides two implementations of DNSSD interface: \n\nDNSSDBindable 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).\n\n**[Update] Since `targetSDK = 31` (Android 12) system's deamon was deprecated by Google. Consider switching to an Embedded version or some other solution.**\n\n```\nDNSSD dnssd = new DNSSDBindable(context); \n```\n\nDNSSDEmbedded 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.\n\n```\nDNSSD dnssd = new DNSSDEmbedded(); \n```\n\n##### Register service\n```java\ntry {\n\tregisterService = dnssd.register(\"service_name\", \"_rxdnssd._tcp\", 123,  \n   \t\tnew RegisterListener() {\n\n\t\t\t@Override\n\t\t\tpublic void serviceRegistered(DNSSDRegistration registration, int flags, \n\t\t\t\tString serviceName, String regType, String domain) {\n\t\t\t\tLog.i(\"TAG\", \"Register successfully \");\n\t\t\t}\n\n\t\t\t@Override\n         \tpublic void operationFailed(DNSSDService service, int errorCode) {\n\t\t\t\tLog.e(\"TAG\", \"error \" + errorCode);\n        \t}\n   \t\t});\n} catch (DNSSDException e) {\n\tLog.e(\"TAG\", \"error\", e);\n}\n```\n\n##### Browse services example\n```java\ntry {\n\tbrowseService = dnssd.browse(\"_rxdnssd._tcp\", new BrowseListener() {\n                \n \t\t@Override\n\t\tpublic void serviceFound(DNSSDService browser, int flags, int ifIndex, \n\t\t\tfinal String serviceName, String regType, String domain) {\n\t\t\tLog.i(\"TAG\", \"Found \" + serviceName);\n\t\t}\n\n\t\t@Override\n\t\tpublic void serviceLost(DNSSDService browser, int flags, int ifIndex, \n\t\t\tString serviceName, String regType, String domain) {\n\t\t\tLog.i(\"TAG\", \"Lost \" + serviceName);\n\t\t}\n\n\t\t@Override\n\t\tpublic void operationFailed(DNSSDService service, int errorCode) {\n\t\t\tLog.e(\"TAG\", \"error: \" + errorCode);\n\t\t}        \n\t});\n} catch (DNSSDException e) {\n\tLog.e(\"TAG\", \"error\", e);\n}\n```\n\nYou can find more samples in app inside this repository.\n\n### RxDNSSD\n\n- RxDnssdBindable\n```\nRxDnssd rxdnssd = new RxDnssdBindable(context); \n```\n- RxDnssdEmbedded\n```\nRxDnssd rxdnssd = new RxDnssdEmbedded(); \n```\n\n##### Register service\n```java\nBonjourService bs = new BonjourService.Builder(0, 0, Build.DEVICE, \"_rxdnssd._tcp\", null).port(123).build();\nSubscription subscription = rxdnssd.register(bonjourService)\n      .observeOn(AndroidSchedulers.mainThread())\n      .subscribe(service -\u003e {\n      \t\tupdateUi();\n      }, throwable -\u003e {\n        \tLog.e(\"DNSSD\", \"Error: \", throwable);\n      });\n```\n\n##### Browse services example\n```java\nSubscription subscription = rxDnssd.browse(\"_http._tcp\", \"local.\")\n\t.compose(rxDnssd.resolve())\n    .compose(rxDnssd.queryRecords())\n    .subscribeOn(Schedulers.io())\n    .observeOn(AndroidSchedulers.mainThread())\n    .subscribe(new Action1\u003cBonjourService\u003e() {\n    \t@Override\n        public void call(BonjourService bonjourService) {\n        \tLog.d(\"TAG\", bonjourService.toString());\n        }\n    }, new Action1\u003cThrowable\u003e() {\n        @Override\n        public void call(Throwable throwable) {\n        \tLog.e(\"TAG\", \"error\", throwable);\n        }\n\t});\n```\n\n### Rx2DNSSD\n\n- Rx2DnssdBindable\n```\nRx2Dnssd rxdnssd = new Rx2DnssdBindable(context); \n```\n- Rx2DnssdEmbedded\n```\nRx2Dnssd rxdnssd = new Rx2DnssdEmbedded(); \n```\n\n##### Register service\n```java\nBonjourService bs = new BonjourService.Builder(0, 0, Build.DEVICE, \"_rxdnssd._tcp\", null).port(123).build();\nregisterDisposable = rxDnssd.register(bs)\n        .subscribeOn(Schedulers.io())\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribe(bonjourService -\u003e {\n            Log.i(\"TAG\", \"Register successfully \" + bonjourService.toString());\n        }, throwable -\u003e {\n            Log.e(\"TAG\", \"error\", throwable);\n        });\n```\n\n##### Browse services example\n```java\nbrowseDisposable = rxDnssd.browse(\"_http._tcp\", \"local.\")\n        .compose(rxDnssd.resolve())\n        .compose(rxDnssd.queryRecords())\n        .subscribeOn(Schedulers.io())\n        .observeOn(AndroidSchedulers.mainThread())\n        .subscribe(bonjourService -\u003e {\n            Log.d(\"TAG\", bonjourService.toString());\n            if (bonjourService.isLost()) {\n                mServiceAdapter.remove(bonjourService);\n            } else {\n                mServiceAdapter.add(bonjourService);\n            }\n        }, throwable -\u003e Log.e(\"TAG\", \"error\", throwable));\n```\n\nLicense\n-------\n\tCopyright (C) 2022 Andriy Druk\n\n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandriydruk%2FRxDNSSD","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandriydruk%2FRxDNSSD","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandriydruk%2FRxDNSSD/lists"}