1 |
|
2 |
|
3 | import { RemoteInfo } from "dgram";
|
4 |
|
5 | declare function bonjour(opts?: bonjour.BonjourOptions): bonjour.Bonjour;
|
6 | export = bonjour;
|
7 | declare namespace bonjour {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | interface Browser extends NodeJS.EventEmitter {
|
23 | services: RemoteService[];
|
24 | start(): void;
|
25 | update(): void;
|
26 | stop(): void;
|
27 | on(event: "up" | "down", listener: (service: RemoteService) => void): this;
|
28 | once(event: "up" | "down", listener: (service: RemoteService) => void): this;
|
29 | removeListener(event: "up" | "down", listener: (service: RemoteService) => void): this;
|
30 | removeAllListeners(event?: "up" | "down"): this;
|
31 | }
|
32 | interface BrowserOptions {
|
33 | type?: string | undefined;
|
34 | subtypes?: string[] | undefined;
|
35 | protocol?: string | undefined;
|
36 | txt?: { [key: string]: string } | undefined;
|
37 | }
|
38 |
|
39 | interface ServiceOptions {
|
40 | name: string;
|
41 | host?: string | undefined;
|
42 | port: number;
|
43 | type: string;
|
44 | subtypes?: string[] | undefined;
|
45 | protocol?: "udp" | "tcp" | undefined;
|
46 | txt?: { [key: string]: string } | undefined;
|
47 | probe?: boolean | undefined;
|
48 | }
|
49 |
|
50 | interface BaseService {
|
51 | name: string;
|
52 | fqdn: string;
|
53 | host: string;
|
54 | port: number;
|
55 | type: string;
|
56 | protocol: string;
|
57 | subtypes: string[];
|
58 | txt: { [key: string]: string };
|
59 | }
|
60 | interface RemoteService extends BaseService {
|
61 | referer: RemoteInfo;
|
62 | rawTxt: Buffer;
|
63 | addresses: string[];
|
64 | }
|
65 | interface Service extends BaseService, NodeJS.EventEmitter {
|
66 | published: boolean;
|
67 | addresses: string[];
|
68 |
|
69 | stop(cb?: () => void): void;
|
70 | start(): void;
|
71 | }
|
72 | interface BonjourOptions {
|
73 | type?: "udp4" | "udp6" | undefined;
|
74 | multicast?: boolean | undefined;
|
75 | interface?: string | undefined;
|
76 | port?: number | undefined;
|
77 | ip?: string | undefined;
|
78 | ttl?: number | undefined;
|
79 | loopback?: boolean | undefined;
|
80 | reuseAddr?: boolean | undefined;
|
81 | }
|
82 | interface Bonjour {
|
83 | (opts?: BonjourOptions): Bonjour;
|
84 | publish(options: ServiceOptions): Service;
|
85 | unpublishAll(cb?: () => void): void;
|
86 | find(options: BrowserOptions, onUp?: (service: RemoteService) => void): Browser;
|
87 | findOne(options: BrowserOptions, cb?: (service: RemoteService) => void): Browser;
|
88 | destroy(): void;
|
89 | }
|
90 | }
|