How to use bonjour - 4 common examples

To help you get started, we’ve selected a few bonjour examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Opentrons / opentrons / app / src / robot / api-client / discovery.js View on Github external
export function handleDiscover (dispatch, state, action) {
  // disable legacy discovery if new discovery feature flag is set
  if (state.config.discovery.enabled) return

  // don't duplicate discovery requests
  // TODO(mc, 2018-09-10): did not use selector to avoid circular dependency
  // this file is getting ditched so ¯\_(ツ)_/¯
  if (state.discovery.scanning) return

  // TODO(mc, 2017-10-26): we're relying right now on the fact that resin
  // advertises an SSH service. Instead, we should be registering an HTTP
  // service on port 31950 and listening for that instead
  const browser = Bonjour().find({type: 'http'})
    .on(UP_EVENT, handleServiceUp)
    .on(DOWN_EVENT, handleServiceDown)

  let pollInterval
  if (!SKIP_WIRED_POLL) {
    pollInterval = setInterval(pollDirectConnection, DIRECT_POLL_INTERVAL_MS)
  }

  setTimeout(finishDiscovery, DISCOVERY_TIMEOUT_MS)

  function handleServiceUp (service) {
    if (NAME_RE.test(service.name)) {
      const serviceWithIp = withIp(service)
      dispatch(actions.addDiscovered(serviceWithIp))

      // fetchHealth is a thunk action, so give it dispatch
github DefinitelyTyped / DefinitelyTyped / bonjour / bonjour-tests.ts View on Github external
import * as bonjour from 'bonjour';

var bonjourOptions: bonjour.BonjourOptions;
var bonjourInstance: bonjour.Bonjour;

var serviceOptions: bonjour.ServiceOptions;
var service: bonjour.Service;

var browserOptions: bonjour.BrowserOptions;
var browser: bonjour.Browser;

bonjourOptions = { interface: '192.168.1.1', port: 5353 };
bonjourInstance = new bonjour.Bonjour(bonjourOptions);

serviceOptions = { name: 'My Web Server', type: 'http', port: 3000 };
service = bonjourInstance.publish(serviceOptions);

browserOptions = { protocol: 'tcp', type: 'http' };
browser = bonjour.find(browserOptions);
github DefinitelyTyped / DefinitelyTyped / bonjour / bonjour-tests.ts View on Github external
var bonjourInstance: bonjour.Bonjour;

var serviceOptions: bonjour.ServiceOptions;
var service: bonjour.Service;

var browserOptions: bonjour.BrowserOptions;
var browser: bonjour.Browser;

bonjourOptions = { interface: '192.168.1.1', port: 5353 };
bonjourInstance = new bonjour.Bonjour(bonjourOptions);

serviceOptions = { name: 'My Web Server', type: 'http', port: 3000 };
service = bonjourInstance.publish(serviceOptions);

browserOptions = { protocol: 'tcp', type: 'http' };
browser = bonjour.find(browserOptions);
github watson / ipp-printer / index.js View on Github external
this.server.listen(opts.port, function () {
    self.port = self.server.address().port
    debug('IPP printer "%s" listening on port %s', self.name, self.port)
    if (opts.zeroconf) bonjour.tcp.publish({ type: 'ipp', port: self.port, name: self.name })
  })

bonjour

A Bonjour/Zeroconf implementation in pure JavaScript

MIT
Latest version published 8 years ago

Package Health Score

66 / 100
Full package analysis