UNPKG

941 BTypeScriptView Raw
1/// <reference types="node" />
2import * as events from 'events';
3import * as WebSocket from 'ws';
4export interface CommServerConnectionPayload {
5 event: 'connect';
6 device: string;
7}
8export interface CommServer {
9 on(event: 'error', listener: (err: Error) => void): this;
10 on(event: 'connect', listener: (data: CommServerConnectionPayload) => void): this;
11}
12export declare class CommServer extends events.EventEmitter {
13 namespace: string;
14 /**
15 * Unique identifier of the publisher.
16 */
17 id: string;
18 /**
19 * Port of communication server.
20 */
21 port: number;
22 protected server?: WebSocket.Server;
23 constructor(namespace: string,
24 /**
25 * Unique identifier of the publisher.
26 */
27 id: string,
28 /**
29 * Port of communication server.
30 */
31 port: number);
32 get clients(): Set<WebSocket>;
33 start(): Promise<void>;
34 private parseData;
35 stop(): Promise<void>;
36}