/// <reference types="node" />
/// <reference types="socket.io" />
import { Node } from 'slate';
import { Server } from 'http';
import AutomergeBackend from './AutomergeBackend';
import { SocketIOConnection } from 'index';
export interface SocketIOCollaborationOptions {
    entry: Server;
    connectOpts?: SocketIO.ServerOptions;
    defaultValue?: Node[];
    saveFrequency?: number;
    cleanFrequency?: number;
    cleanThreshold?: number;
    onAuthRequest?: (query: Object, socket?: SocketIO.Socket) => Promise<boolean> | boolean;
    onDocumentLoad?: (pathname: string, query?: Object) => Promise<Node[]> | Node[];
    onDocumentSave?: (pathname: string, doc: Node[]) => Promise<void> | void;
    onSocketConnection?: (metadata: ConnectionCallbackMeta) => Promise<void> | void;
    onSocketDisconnection?: (metadata: ConnectionCallbackMeta) => Promise<void> | void;
}
export interface BackendCounts {
    [key: string]: number;
}
export interface ConnectionCallbackMeta {
    docId: string;
    socket: SocketIO.Socket;
    _this: SocketIOConnection;
}
export interface Backends {
    automerge: AutomergeBackend;
    ready: boolean;
    failed: boolean;
    cleanupTimer: number;
}
export default class SocketIOCollaboration {
    private io;
    private options;
    private backends;
    private backendCounts;
    /**
     * Constructor
     */
    constructor(options: SocketIOCollaborationOptions);
    /**
     * Initial IO configuration
     */
    private configure;
    /**
     * Namespace SocketIO middleware. Load document value and append it to CollaborationBackend.
     */
    private nspMiddleware;
    /**
     * init function to set up new documents is they don't exist.  These get cleaned up once
     * all the sockets disconnect.
     * @param socket
     */
    private init;
    /**
     * memory cleaner process that checks the backeds to see if there aren't connections and if the timer has expired.
     */
    private cleaner;
    /**
     * SocketIO auth middleware. Used for user authentification.
     */
    private authMiddleware;
    /**
     * On 'connect' handler.
     */
    private onConnect;
    /**
     * On 'message' handler
     */
    private onMessage;
    /**
     * forces the backend to save the document
     * @param name
     */
    private onFlush;
    private autoSaveDoc;
    /**
     * Save document
     */
    private saveDocument;
    /**
     * On 'disconnect' handler
     */
    private onDisconnect;
    /**
     * Clean up unused cursor data.
     */
    garbageCursors: (nsp: string) => void;
    /**
     * Destroy SocketIO connection
     */
    destroy: () => Promise<void>;
}
//# sourceMappingURL=SocketIOConnection.d.ts.map