/// <reference types="node" />
import * as dgram from 'dgram';
import { EventEmitter } from 'events';
declare module 'dgram' {
    function createSocket(options: {
        type: string;
        reuseAddr?: boolean;
    }, callback?: (msg: Buffer, rinfo: RemoteInfo) => void): Socket;
}
export declare type NetworkOptions = {
    instanceUuid: string;
    address: string;
    port: number;
    key: string | null;
    reuseAddr: boolean;
    dictionary?: string[];
};
export declare abstract class Network extends EventEmitter {
    protected socket: dgram.Socket | null;
    protected destinations: Set<string>;
    private address;
    private port;
    private key;
    private reuseAddr;
    private instanceUuid;
    private dictionary;
    constructor(options: NetworkOptions);
    start(): Promise<void>;
    stop(): void;
    send(event: string, ...data: any[]): Promise<void>;
    protected abstract bonded(address: string): void;
    protected sendToDest(destination: string, messages: Buffer[], port?: number): Promise<void>;
    private msgWaitingAckBuffers;
    protected prepareMessage(event: string, maxRetries: number, requireAck: false | ((buffers: Buffer[]) => void), ...data: any[]): Promise<[Buffer[], null | Promise<void>]>;
    private encode(data);
    private msgBuffers;
    private decode(data, rinfo);
}
export declare class MulticastNetwork extends EventEmitter {
    private multicastAddress;
    private ttl;
    private options;
    private networks;
    constructor(multicastAddress: string, ttl: number, options: NetworkOptions);
    start(): Promise<void>;
    stop(): void;
    send(event: string, ...data: any[]): Promise<void>;
}
declare module 'dgram' {
    interface Socket extends EventEmitter {
        setMulticastInterface(multicastInterface: string): void;
    }
}
export declare class BroadcastNetwork extends Network {
    private broadcast;
    constructor(broadcastAddress: string | undefined, options: NetworkOptions);
    protected bonded(address: string): void;
}
export declare class DynamicUnicastNetwork extends Network {
    private unicast;
    constructor(options: NetworkOptions, unicastAddresses?: string | string[]);
    add(address: string): void;
    remove(address: string): void;
    sendTo(destination: string, port: number, event: string, maxRetries: number, ...data: any[]): Promise<void>;
    protected bonded(address: string): void;
}
