module import * as chalk from "chalk" ; import { checkDebugFlag , make_debugLog } from "node-opcua-debug" ; import { ServerSidePublishEngine , ServerSidePublishEngineOptions } from "./server_publish_engine" ; import { Subscription } from "./server_subscription" ; const debugLog = make_debugLog ( __filename ) ; const doDebug = checkDebugFlag ( __filename ) ; internal export class ServerSidePublishEngineForOrphanSubscription extends ServerSidePublishEngine { constructor ( options ) { super ( options ) ; } public add_subscription ( subscription ) { debugLog ( chalk . bgCyan . yellow . bold ( " adding live subscription with id=" ) , subscription . id , " to orphan" ) ; super . add_subscription ( subscription ) ; ( subscription as any ) . _expired_func = function ( this ) { debugLog ( chalk . bgCyan . yellow ( " Removing expired subscription with id=" ) , this . id , " from orphan" ) ; } ; subscription . on ( "expired" , ( subscription as any ) . _expired_func ) ; return subscription ; } public detach_subscription ( subscription ) { super . detach_subscription ( subscription ) ; subscription . removeListener ( "expired" , ( subscription as any ) . _expired_func ) ; ( subscription as any ) . _expired_func = null ; return subscription ; } }