Zeroconf

Contents

This plugin allows you to browse and publish Zeroconf/Bonjour/mDNS services.

https://github.com/becvert/cordova-plugin-zeroconf

Ionic Zeroconf插件的安装(Installation)

ionic cordova plugin add cordova-plugin-zeroconf npm install @ionic-native/zeroconf

Ionic Zeroconf插件支持的平台(Supported Platforms)

  • Android
  • iOS

Ionic Zeroconf插件的用法(Usage)

import { Zeroconf } from '@ionic-native/zeroconf';

constructor(private zeroconf: Zeroconf) { }

...

// watch for services of a specified type
this.zeroconf.watch('_http._tcp.', 'local.').subscribe(result => {
  if (result.action == 'added') {
    console.log('service added', result.service);
  } else {
    console.log('service removed', result.service);
  }
});

// publish a zeroconf service of your own
this.zeroconf.register('_http._tcp.', 'local.', 'Becvert\'s iPad', 80, {
  'foo': 'bar'
}).then(result => {
  console.log('Service registered', result.service);
});


// unregister your service
this.zeroconf.unregister('_http._tcp.', 'local.', 'Becvert\'s iPad');