source: trip-planner-front/node_modules/bonjour/index.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 922 bytes
Line 
1'use strict'
2
3var Registry = require('./lib/registry')
4var Server = require('./lib/mdns-server')
5var Browser = require('./lib/browser')
6
7module.exports = Bonjour
8
9function Bonjour (opts) {
10 if (!(this instanceof Bonjour)) return new Bonjour(opts)
11 this._server = new Server(opts)
12 this._registry = new Registry(this._server)
13}
14
15Bonjour.prototype.publish = function (opts) {
16 return this._registry.publish(opts)
17}
18
19Bonjour.prototype.unpublishAll = function (cb) {
20 this._registry.unpublishAll(cb)
21}
22
23Bonjour.prototype.find = function (opts, onup) {
24 return new Browser(this._server.mdns, opts, onup)
25}
26
27Bonjour.prototype.findOne = function (opts, cb) {
28 var browser = new Browser(this._server.mdns, opts)
29 browser.once('up', function (service) {
30 browser.stop()
31 if (cb) cb(service)
32 })
33 return browser
34}
35
36Bonjour.prototype.destroy = function () {
37 this._registry.destroy()
38 this._server.mdns.destroy()
39}
Note: See TracBrowser for help on using the repository browser.