import type { IncomingMessage } from 'node:http';
import { BaseMessage, HandlerRequestData, InvokePrefixes, ISrpcServerOptions, RequestData, ResponseData, SrpcDisconnectCause, SrpcMeta, SrpcStream, TSrpcMessageHandlerFnOrClass } from './types';
export declare class SrpcServer<TMeta extends SrpcMeta = SrpcMeta, TClientOutput extends BaseMessage = BaseMessage, TServerOutput extends BaseMessage = BaseMessage> {
    private readonly options;
    private readonly logger;
    private readonly wsServer;
    private readonly streamConnectionHandlers;
    private readonly streamDisconnectionHandlers;
    private readonly streamMessageHandlers;
    private readonly blockedClientRequests;
    private readonly pendingClientRequests;
    private readonly cleanupUpgradeHandler?;
    private readonly inactivityCheckInterval;
    private clientAuthorizer?;
    private clientKeyFetcher?;
    readonly streamsById: Map<string, SrpcStream<TMeta>>;
    readonly streamsByClientId: Map<string, SrpcStream<TMeta>>;
    protected readonly pendingStreamsByClientId: Map<string, SrpcStream<TMeta>>;
    constructor(options: ISrpcServerOptions<TClientOutput, TServerOutput>);
    private readonly verifyClient;
    private attachConnection;
    private createStream;
    private handleStreamEstablished;
    protected postEstablishCheck(_stream: SrpcStream<TMeta>): Promise<boolean>;
    protected getCurrentStreamByClientId(clientId: string): SrpcStream<TMeta> | undefined;
    protected isCurrentStream(stream: SrpcStream<TMeta>): boolean;
    private activateStream;
    private handleWsMessage;
    private handleStreamDataReceived;
    private openClientRequests;
    private handleByteSubstreamOperation;
    private handleClientRequest;
    protected runMessageHandler(handler: TSrpcMessageHandlerFnOrClass<SrpcStream<TMeta>, unknown, unknown>, stream: SrpcStream<TMeta>, data: unknown): Promise<unknown>;
    protected onStreamConnected(stream: SrpcStream<TMeta>): Promise<void>;
    protected onStreamActivated(_stream: SrpcStream<TMeta>): void | Promise<void>;
    protected onStreamDisconnected(stream: SrpcStream<TMeta>, cause: SrpcDisconnectCause): void;
    protected cleanupStream(stream: SrpcStream<TMeta>, cause?: SrpcDisconnectCause): void;
    private handleStreamDisconnected;
    private handleStreamError;
    private terminateInactiveStreams;
    private validateClientAuth;
    private fetchClientKey;
    private getRemoteAddress;
    private writeToStream;
    private writeToStreamAsync;
    private closeStreamWithError;
    setClientAuthorizer(authorizer: (metadata: any, req: IncomingMessage) => Promise<boolean | Partial<TMeta>> | boolean | Partial<TMeta>): void;
    setClientKeyFetcher(fetcher: (clientId: string) => Promise<false | string> | false | string): void;
    registerConnectionHandler(handler: (stream: SrpcStream<TMeta>) => void | Promise<void>): void;
    registerMessageHandler<P extends InvokePrefixes<TClientOutput, TServerOutput>>(prefix: P, handler: TSrpcMessageHandlerFnOrClass<SrpcStream<TMeta>, HandlerRequestData<TClientOutput, P>, ResponseData<TServerOutput, P>>): void;
    registerDisconnectHandler(handler: (stream: SrpcStream<TMeta>, cause: SrpcDisconnectCause) => void): void;
    invoke<P extends InvokePrefixes<TServerOutput, TClientOutput>>(stream: SrpcStream<TMeta>, prefix: P, data: RequestData<TServerOutput, P>, timeoutMs?: number): Promise<ResponseData<TClientOutput, P>>;
    close(): void;
    static createInvoke<TM extends SrpcMeta, TCO extends BaseMessage, TSO extends BaseMessage>(instanceFn: () => SrpcServer<TM, TCO, TSO>): SrpcServer<TM, TCO, TSO>['invoke'];
}
//# sourceMappingURL=SrpcServer.d.ts.map