Last change
on this file since 1ad8e64 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 |
|
---|
3 | var Registry = require('./lib/registry')
|
---|
4 | var Server = require('./lib/mdns-server')
|
---|
5 | var Browser = require('./lib/browser')
|
---|
6 |
|
---|
7 | module.exports = Bonjour
|
---|
8 |
|
---|
9 | function 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 |
|
---|
15 | Bonjour.prototype.publish = function (opts) {
|
---|
16 | return this._registry.publish(opts)
|
---|
17 | }
|
---|
18 |
|
---|
19 | Bonjour.prototype.unpublishAll = function (cb) {
|
---|
20 | this._registry.unpublishAll(cb)
|
---|
21 | }
|
---|
22 |
|
---|
23 | Bonjour.prototype.find = function (opts, onup) {
|
---|
24 | return new Browser(this._server.mdns, opts, onup)
|
---|
25 | }
|
---|
26 |
|
---|
27 | Bonjour.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 |
|
---|
36 | Bonjour.prototype.destroy = function () {
|
---|
37 | this._registry.destroy()
|
---|
38 | this._server.mdns.destroy()
|
---|
39 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.