import { Server, ServerOptions, Socket } from "socket.io";
import { HotHTTPServer } from "./HotHTTPServer";
import { HotWebSocketServerClient } from "./HotWebSocketServerClient";
import { HotLog } from "./HotLog";
import { HotRoute } from "./HotRoute";
import { HotRouteMethod, ServerAuthorizationFunction } from "./HotRouteMethod";
/**
 * A web socket server.
 */
export declare class HotWebSocketServer {
    /**
     * The parent HTTP server.
     */
    protected connection: HotHTTPServer;
    /**
     * The logger.
     */
    logger: HotLog;
    /**
     * The Websocket server.
     */
    protected io: Server;
    /**
     * The routes to attach to incoming connections.
     */
    protected routes: {
        [name: string]: HotRoute;
    };
    /**
     * The connected clients.
     */
    clients: {
        [socketId: string]: HotWebSocketServerClient;
    };
    /**
     * The tags and their associated clients.
     */
    tags: {
        [tag: string]: {
            [socketId: string]: HotWebSocketServerClient;
        };
    };
    /**
     * The socket.io server options. Default options are:
     * ```json
     * {
     * 	"cors": {
     * 		"origin": this.connection.cors.origin,
     * 		"allowedHeaders": this.connection.cors.allowedHeaders
     * 	}
     * }
     * ```
     * Where this.connection.cors represents the CORS settings set for the
     * HotStaq processor.
     */
    serverOptions: Partial<ServerOptions>;
    /**
     * Executes when authorizing a called method. The value returned from
     * here will be passed to onServerExecute. Undefined returning from here
     * will mean the authorization failed. If any exceptions are thrown from
     * this function, they will be sent to the client as an { error: string; }
     * object with the exception message as the error.
     *
     * The socket.handshake.auth will be passed into the jsonObj in the
     * ServerRequest parameter.
     */
    onServerAuthorize: ServerAuthorizationFunction;
    /**
     * Executes after a successful connection.
     */
    onSuccessfulConnection: (client: HotWebSocketServerClient) => Promise<void>;
    /**
     * Executes right when a user connects before onServerAuthorize is called.
     * If this function returns false, the connection will be closed. Be sure
     * to use onServerAuthorize to handle authorization, NOT here.
     */
    onConnection: (socket: Socket) => Promise<boolean>;
    /**
     * Executes after a connection is unable to authenticate.
     */
    onConnectionError: (socket: Socket, errorMessage: string) => Promise<void>;
    /**
     * Executes right after a user disconnects.
     */
    onDisconnect: (socket: HotWebSocketServerClient) => void;
    constructor(server: HotHTTPServer);
    /**
     * Setup the WebSocket server AFTER the http server is running.
     */
    setup(): void;
    /**
     * Get the IP address from a socket.
     */
    static getIPFromSocket(socket: Socket): string;
    /**
     * Tag a client. This is useful when trying to send messages to groups of clients.
     */
    tagClient(client: HotWebSocketServerClient, tag: string): void;
    /**
     * Get a list of clients with the same tag.
     */
    getTaggedClients(tag: string): {
        [tag: string]: HotWebSocketServerClient;
    };
    /**
     * Clears the list of clients with the same tag.
     */
    clearTag(tag: string): void;
    /**
     * Clears the list of tagged clients.
     */
    clearAllTags(): void;
    /**
     * Send an event to all clients with the same tag.
     */
    sendToTaggedClients(tag: string, event: string, data: any): void;
    /**
     * Send an event to all clients.
     */
    sendToAll(event: string, data: any): void;
    /**
     * Send an event to a client.
     */
    send(clientId: string, event: string, data: any): void;
    /**
     * Disconnect all clients with the same tag.
     */
    disconnectTaggedClients(tag: string, closeConnection?: boolean): void;
    /**
     * Disconnect all clients.
     */
    disconnectAll(closeConnection?: boolean): void;
    /**
     * Send a client.
     */
    disconnect(clientId: string, closeConnection?: boolean): void;
    /**
     * Add a route for socket.io. These will only be added to new
     * connections. Existing connections will not receive these.
     */
    addRoute(route: HotRoute | string, routeMethod?: HotRouteMethod | string, executeFunction?: (jsonObj: any) => Promise<any>): void;
    /**
     * Stop the socket.io server.
     */
    stop(): Promise<void>;
}
//# sourceMappingURL=HotWebSocketServer.d.ts.map