import * as SocketIO from 'socket.io'; import { DyFM_AnyError } from '@futdevpro/fsm-dynamo'; import { DyFM_SocketEvent, DyFM_SocketEventTask } from '@futdevpro/fsm-dynamo/socket'; import { DyNTS_SingletonService } from '../../../_services/base/singleton.service'; import { DyNTS_SocketSecurity } from '../_enums/socket-security.enum'; import { DyNTS_SocketPresence } from '../_models/socket-presence.control-model'; import { DyNTS_SocketServerService_Params } from '../_models/socket-server-service-params.control-model'; /** Opciók a setupSocketServer híváshoz: attacholt HTTP szerver esetén ne hívjuk a listen()-t. */ export interface DyNTS_SocketServerSetupOptions { /** Ha true, a Socket.IO egy már listenelő HTTP/HTTPS szerverre van attacholva – ne hívjuk a listen()-t. */ attachedToExistingServer?: boolean; /** A tényleges port (pl. defaultolt httpPort/httpsPort) – logokban használjuk. */ effectivePort?: number; } /** * You need to define the following functions: * ```ts * getServiceParams(): DyNTS_SocketServerServiceParams; * * getIncomingEvents(): DyFM_SocketEvent[]; * * getPresenceFromSubscriptionEventContent( * socketSubscription: T_SubscriptionContent, * socket: SocketIO.Socket * ): Promise; * ``` */ export declare abstract class DyNTS_SocketServerService extends DyNTS_SingletonService { protected params: DyNTS_SocketServerService_Params; get name(): string; get port(): number | undefined; get security(): DyNTS_SocketSecurity; get activeSubscriptionsCount(): number; protected openSocketServer: SocketIO.Server; protected secureSocketServer: SocketIO.Server; protected incomingEvents: DyFM_SocketEvent[]; protected presences: T_Presence[]; get logSetup(): boolean; get highDetailedLogs(): boolean; readonly defaultErrorUserMsg: string; protected constructor(); /** * You need to setup a function that converts subscription event content to presence. * You should do authentication and authorization here. */ protected abstract getPresenceFromSubscriptionEventContent(socketSubscription: T_SubscriptionContent, socket: SocketIO.Socket): Promise; private asyncConstructor; /** * You must setup events and required services for this function */ private prepareEvents; setupSocketServer(newSocketServer: SocketIO.Server, security: DyNTS_SocketSecurity.open | DyNTS_SocketSecurity.secure, successCallback: () => void, options?: DyNTS_SocketServerSetupOptions): Promise; protected addSocketToPresence(newPresence: T_Presence): Promise; protected closeSocket(socket: SocketIO.Socket, issuer: string, withError?: DyFM_AnyError): Promise; protected removeSocketFromPresence(socket: SocketIO.Socket): Promise; private disconnectBaseTask; private removeSubscription; idIsSubscribed(id: string): boolean; emitError(presenceIssuerId: string, error: any, issuer: string): Promise; sendEventForId(id: string, event: string, content: any, issuer: string): Promise; broadcastEvent(event: string, content: any, issuer: string): Promise; sendError(error: DyFM_AnyError, issuer: string): Promise; private _getDefaultErrorSettings; /** * You must setup params for the service in this function */ protected abstract getServiceParams(): DyNTS_SocketServerService_Params; /** * You must setup events and required services in this function */ protected abstract getIncomingEvents(): DyFM_SocketEvent[]; /** * You can setup tasks for the subscription event in this function */ /** * You can setup preprocesses for the subscription event in this function */ /** * You can setup tasks for the subscription event in this function * This will happen after the presence is created * If this throws an error, the socket will be closed */ protected getSubscriptionTasks?(): DyFM_SocketEventTask[]; /** * You can setup tasks for the unsubscribe event in this function */ /** * You can setup preprocesses for the unsubscribe event in this function */ /** * You can setup tasks for the error event in this function */ protected errorHandling?: DyFM_SocketEventTask; } //# sourceMappingURL=socket-server.service.d.ts.map