@mdf.js/socket-server-provider
Version:
MMS - Socket.io Server Port for Javascript/Typescript
56 lines • 2.21 kB
TypeScript
/**
* Copyright 2024 Mytra Control S.L. All rights reserved.
*
* Use of this source code is governed by an MIT-style license that can be found in the LICENSE file
* or at https://opensource.org/licenses/MIT.
*/
import { Layer } from '@mdf.js/core';
import { LoggerInstance } from '@mdf.js/logger';
import { Config, Server } from './types';
export declare class Port extends Layer.Provider.Port<Server, Config> {
/** Socket.io server handler */
private readonly instance;
/** HTTP server provider instance */
private readonly httpServer;
/** Event wrapping flags */
private isWrapped;
/**
* Implementation of functionalities of an Socket.io server port instance.
* @param config - Port configuration options
* @param logger - Port logger, to be used internally
*/
constructor(config: Config, logger: LoggerInstance);
/** Return the underlying port instance */
get client(): Server;
/** Return the port state as a boolean value, true if the port is available, false in otherwise */
get state(): boolean;
/** Initialize the port instance */
start(): Promise<void>;
/** Stop the port instance */
stop(): Promise<void>;
/** Close the port instance */
close(): Promise<void>;
/**
* Auxiliar function to log and emit events
* @param event - original event name
* @param args - arguments to be emitted with the event
*/
private onEvent;
/** Callback function for `error` event in the HTTP Provider */
private readonly onErrorEvent;
/** Callback function for `connection` event in socket.io server */
private readonly onConnectionEvent;
/** Callback function for `connection_error` event in engine.io */
private readonly onConnectionErrorEvent;
/**
* Adapts the `server` instance events to standard Port events
* @param instance - Server instance over which the events should be wrapped
*/
private socketIOServerEventsWrapping;
/**
* Clean all the events handlers
* @param instance - Server instance over which the events should be cleaned
*/
private socketIOServerEventsUnwrapping;
}
//# sourceMappingURL=Port.d.ts.map