0.1.1 • Published 9 years ago

react-native-bonjour v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

react-native-bonjour

Basic Bonjour implementation for React-native

This repo has been moved to another naming to be non OSX-specific.

Install

npm i -S react-native-bonjour
  • Right click on the Libraries folder in XCode, and add RNBonjour.xcodeproj
  • Go to your Build Phases, under Link Binary with Libraries, add libRNBonjour.a
  • Click on the RNBonjour.xcodeproj in the Libraries folder, search Header Search Paths and add $(SRCROOT)/../../react-native/React if it's not.

API

import Bonjour from 'react-native-bonjour';
const bonjour = new Bonjour();
Methods
scan(type = 'http', protocol = 'tcp', domain = 'local.') Start the bonjour scan

This will initialize the scan from the Bonjour instance. Will stop another scan if any is running.

stop() Stop the scan

If any scan is running, stop it. Otherwise do nothing.

getServices() Returns resolved services

Will return all names of services that have been resolved.

Events
bonjour.on('start', () => { console.log('The scan has started.'); });
start Triggered on scan start
stop Triggered on scan stop
found Triggered when a service is found

Broadcast the service name.

remove Triggered when a service is removed

Broadcast the service name.

update Triggered either when a service is found or removed
error Triggered when an error occurs

Webpack

This component uses ES6. If using webpack you should launch babel on the Bonjour.js file.