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