1 |
|
2 | import * as dgram from 'dgram';
|
3 | import * as events from 'events';
|
4 | import * as os from 'os';
|
5 | export interface Interface {
|
6 | address: string;
|
7 | broadcast: string;
|
8 | }
|
9 | export interface PublisherMessage {
|
10 | t: number;
|
11 | id: string;
|
12 | nspace: string;
|
13 | name: string;
|
14 | host: string;
|
15 | ip: string;
|
16 | port: number;
|
17 | commPort?: number;
|
18 | path: string;
|
19 | }
|
20 | export interface IPublisherEventEmitter {
|
21 | on(event: 'error', listener: (err: Error) => void): this;
|
22 | }
|
23 | export declare class Publisher extends events.EventEmitter implements IPublisherEventEmitter {
|
24 | namespace: string;
|
25 | name: string;
|
26 | port: number;
|
27 | commPort?: number | undefined;
|
28 | readonly id: string;
|
29 | readonly path = "/";
|
30 | running: boolean;
|
31 | interfaces?: Interface[];
|
32 | protected timer?: NodeJS.Timer;
|
33 | protected interval: number;
|
34 | protected client?: dgram.Socket;
|
35 | constructor(namespace: string, name: string, port: number, commPort?: number | undefined);
|
36 | start(): Promise<void>;
|
37 | stop(): void;
|
38 | protected buildMessage(ip: string): PublisherMessage;
|
39 | protected getInterfaces(): Interface[];
|
40 | protected sayHello(): void;
|
41 | }
|
42 | export declare function prepareInterfaces(interfaces: {
|
43 | [index: string]: os.NetworkInterfaceInfo[];
|
44 | }): Interface[];
|
45 | export declare function newSilentPublisher(namespace: string, name: string, port: number): Publisher;
|
46 | export declare function computeBroadcastAddress(address: string, netmask: string): string;
|