///
import WebSocket, { AddressInfo, WebSocketServer } from 'ws';
import { IncomingMessage, Server as HTTPServer } from 'http';
import { Configuration, Hook } from './types';
import Document from './Document';
import { MessageLogger } from './Debugger';
import { onListenPayload } from '.';
export declare const defaultConfiguration: {
name: null;
port: number;
timeout: number;
debounce: number;
maxDebounce: number;
quiet: boolean;
};
/**
* Hocuspocus Server
*/
export declare class Hocuspocus {
configuration: Configuration;
documents: Map;
httpServer?: HTTPServer;
webSocketServer?: WebSocketServer;
debugger: MessageLogger;
constructor(configuration?: Partial);
/**
* Configure the server
*/
configure(configuration: Partial): Hocuspocus;
get requiresAuthentication(): boolean;
/**
* Start the server
*/
listen(portOrCallback?: number | ((data: onListenPayload) => Promise) | null, callback?: any): Promise;
get address(): AddressInfo;
get URL(): string;
get webSocketURL(): string;
get httpURL(): string;
private showStartScreen;
/**
* Get the total number of active documents
*/
getDocumentsCount(): number;
/**
* Get the total number of active connections
*/
getConnectionsCount(): number;
/**
* Force close one or more connections
*/
closeConnections(documentName?: string): void;
/**
* Destroy the server
*/
destroy(): Promise;
/**
* The `handleConnection` method receives incoming WebSocket connections,
* runs all hooks:
*
* - onConnect for all connections
* - onAuthenticate only if required
*
* … and if nothings fails it’ll fully establish the connection and
* load the Document then.
*/
handleConnection(incoming: WebSocket, request: IncomingMessage, documentName: string, context?: any): void;
/**
* Handle update of the given document
*/
private handleDocumentUpdate;
timers: Map;
/**
* debounce the given function, using the given identifier
*/
debounce(id: string, func: Function, immediately?: boolean): void;
/**
* Create a new document by the given request
*/
private createDocument;
/**
* Create a new connection by the given request and document
*/
private createConnection;
/**
* Run the given hook on all configured extensions.
* Runs the given callback after each hook.
*/
hooks(name: Hook, payload: any, callback?: Function | null): Promise;
/**
* Get parameters by the given request
*/
private static getParameters;
/**
* Get document name by the given request
*/
private getDocumentNameFromRequest;
enableDebugging(): void;
enableMessageLogging(): void;
disableLogging(): void;
disableDebugging(): void;
flushMessageLogs(): this;
getMessageLogs(): any[];
}
export declare const Server: Hocuspocus;