/** * Copyright 2023 Angus.Fenying * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import type * as D from './../Decl'; export type IUnixSocketGatewayOptions = Pick & Partial>; export interface IUnixSocketGateway { /** * The path to the unix socket that server is listening on. * * @type string * @default 'localhost' */ path: string; /** * The maximum length of the queue of pending connections. * * @type uint32 * @default 1023 */ backlog: number; /** * Tells whether the gateway is running or not. */ readonly running: boolean; /** * Register a callback function to be called when the gateway starts listening or closes. * * @param event The event name. * @param callback The callback function. */ on(event: 'listening' | 'close', callback: () => void): this; /** * Register a callback function to be called when the gateway gets an error. * * > The event should always be listened, otherwise the error will be thrown out and program may crash. * * @param event The event name. * @param callback The callback function. */ on(event: 'error', callback: (err: unknown) => void): this; /** * Remove all listeners, or those of the specified event. * * @param event The event name. When omitted, all listeners for all events will be removed. */ removeAllListeners(event?: 'error' | 'listening' | 'close'): this; /** * Start the gateway. * * > If the gateway is already running, this method will do nothing. * > * > When a gateway starts listening successfully, the `listening` event will be emitted. */ start(): Promise; /** * Close all connections and stop the gateway * * > If the gateway is not running, this method will do nothing. * > * > When a gateway stops listening successfully, the `close` event will be emitted. */ stop(): Promise; } /** * Create a new TCP gateway for LwDFX. * * @param opts Options of the gateway */ export declare function createGateway(server: D.IServer, opts: IUnixSocketGatewayOptions): IUnixSocketGateway; //# sourceMappingURL=UnixSocketGateway.d.ts.map