Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nativescript-zeroconf

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nativescript-zeroconf

Zeroconf/Bonjour implementation for NativeScript

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

nativescript-zeroconf

This nativescript-zeroconf plugin provides a Zeroconf/Bonjour implementation for both iOS and Android. Currently, it only supports discovering domains and services in the local network. Should there be any requests, I might implement the service registration parts as well (please open an issue to let me know).

Demo Application

This repository contains a demo application in the demo-angular folder that uses this plugin to display discovered Zeroconf domains and services. The demo app can be a good starting point for your app and may be used for narrowing down issues whilst debugging. Just clone this repo and run npm run demo.ios or npm run demo.android in the src folder.

The demo app searches for by default for http services, but you can easily adjust the serviceType in app/zeroconf/zeroconf.provider.ts.

Installation

tns plugin add nativescript-zeroconf

Usage

First, import the plugin into your provider/component, and, since the plugin returns an Observable also the relevant types:

import { Zeroconf } from 'nativescript-zeroconf';
import { Observable, PropertyChangeData } from 'tns-core-modules/data/observable';

Then, instantiate a Zeroconf and define the event listeners:

    this.zeroconf = new Zeroconf('_http._tcp.', 'local.'); // param 1 = service type, param 2 = domain

    /* define event listener */

    this.zeroconf.on(Observable.propertyChangeEvent, (data: PropertyChangeData) => {
      switch(data.propertyName.toString()) {
        case 'serviceFound': {
          console.log(`serviceFound: ${JSON.stringify(data.value)}`);
          break;
        }
      }
    });

    this.zeroconf.startServiceDiscovery();

Tip: have a look at the demo project for an example implementation

API

Describe your plugin methods and properties here. See nativescript-feedback for example.

PropertyDefaultDescription
some propertyproperty default valueproperty description, default values, etc..
another propertyproperty default valueproperty description, default values, etc..

Limitations

License

MIT license (see LICENSE file)

Keywords

FAQs

Package last updated on 09 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc