Coder Social home page Coder Social logo

easynsd's Introduction

Easy NSD

The EasyNSD library allows for easy integration of network service discovery into your app.


How to Use

Setup

Include the below dependencies in your build.gradle project.

buildscript {
    repositories {
        google()
        maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.4'
        classpath 'com.newtronlabs.android:plugin:5.0.2'
    }
}

allprojects {
    repositories {
        google()
        maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" }
    }
}

subprojects {
    apply plugin: 'com.newtronlabs.android'
}

In the build.gradle for your app.

dependencies {
    compileOnly 'com.newtronlabs.easynsd:easynsd:1.0.1-alpha01'
}

EasyNsd - Service Discovery

In order to discover services we obtain a cient and call discoverServices with the service type to discover.

// Search for services for 5 seconds
EasyNsd.with(this).discoverServices(serviceType = "_ipp._tcp.", timeout = 5 * 1000L).await()

EasyNsd - Registration

To register a service.

val serviceInfoNsd = EasyNsdServiceInfo().apply {
    setServiceName("EasyNsd")
    setServiceType("_ipp._tcp.")
    setPort(1234)
}

// Note: This is a blocking call, user the callback if async behavior is desired.
val serviceInfo = EasyNsd.with(this@MainActivity).registerService(serviceInfoNsd).await()

EasyNsd - Service resolution

Once a service is found it can be resolved by calling resolveService with the service information object found.

val resolvedService = EasyNsd.with(this@MainActivity).resolveService(foundServiceInfoNsd).await()

Support Us

Please support the continued development of these libraries. We host and develop these libraries for free. Any support is deeply appriciated. Thank you!

Support us

BTC Address: 39JmAfnNhaEPKz5wjQjQQj4jcv9BM11NQb


License

https://gist.github.com/NewtronLabs/216f45db2339e0bc638e7c14a6af9cc8

Contact

[email protected]

easynsd's People

Contributors

newtronlabs avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.