UNPKG

1.49 kBTypeScriptView Raw
1/// <reference types="node" />
2import * as dgram from 'dgram';
3import * as events from 'events';
4import * as os from 'os';
5export interface Interface {
6 address: string;
7 broadcast: string;
8}
9export 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}
20export interface IPublisherEventEmitter {
21 on(event: 'error', listener: (err: Error) => void): this;
22}
23export 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}
42export declare function prepareInterfaces(interfaces: {
43 [index: string]: os.NetworkInterfaceInfo[];
44}): Interface[];
45export declare function newSilentPublisher(namespace: string, name: string, port: number): Publisher;
46export declare function computeBroadcastAddress(address: string, netmask: string): string;