import { EventEmitter } from './events';
import type { Emitter } from './emitter';
import type { EventEmitterOptionsType } from './events/types';
declare global {
    var $PRunningEventsServer: EventsServer<Emitter>;
}
/**
 * The idea of an event server is to keep the application running so that it can receive requests from other servers
 * and vice versa.
 *
 * It's kinda the same as how express works but the difference is that we do not start an http server and doesn't rely
 * on process.nextTick.
 *
 * IMPORTANT: This server is not tied to palmares, we create this here to wrap it around the actual EventsAppServer. The
 * idea is that this should not need to be tied to palmares and could work outside of it normally.
 */
export declare class EventsServer<TEmitter extends Emitter> extends EventEmitter<TEmitter> {
    #private;
    /**
     * This is used for appending the promise of adding the event listener to an array so when we initialize the server
     * we can wait for all the callbacks to be appended and listen for events.
     */
    addEventListener(...params: Parameters<EventEmitter['addEventListener']>): Promise<() => Promise<void>>;
    /**
     * This is used for appending the promise of adding the event listener to an array so when we initialize the server
     * we can wait for all the callbacks to be appended and listen for events.
     */
    addEventListenerWithoutResult(...params: Parameters<EventEmitter['addEventListenerWithoutResult']>): Promise<() => Promise<void>>;
    /**
     * Listens for a request and keeps the application running, see here:
     * https://stackoverflow.com/questions/23622051/how-to-forcibly-keep-a-node-js-process-from-terminating/47456805#47456805
     *
     * @param callback - Receives a function that should be called prior to starting the server.
     */
    listen(callback: () => void): Promise<void>;
    /**
     * If an interval had been created then we use this function to remove it so the connection is not kept alive.
     *
     * Also we use this so we can unsubscribe everything from the layer and unsubscribe all of it's listeners.
     */
    close(): Promise<void>;
}
export declare function eventsServer<TEmitter extends typeof Emitter = typeof Emitter>(emitter: Promise<{
    default: TEmitter;
}> | TEmitter, options?: EventEmitterOptionsType & {
    emitterParams?: Parameters<TEmitter['new']>;
}): Promise<EventsServer<InstanceType<TEmitter>>>;
export declare function setEventsServer(server: EventsServer<Emitter>): void;
export declare function getEventsServer<TEmitter extends typeof Emitter = typeof Emitter>(): EventsServer<InstanceType<TEmitter>>;
//# sourceMappingURL=server.d.ts.map