import { IProcessState } from ".." ; import { IPCManager , ProcessListener } from ".." ; export class LocalManager < S extends IProcessState > extends IPCManager < S > { public channels : { [ id ] : ProcessListener < any > ; } = { } ; constructor ( ) { super ( { processId : "" + process . pid , } ) ; } public async requestProcess < T > ( id , method , data ) { const listener = this . requestHandlers [ method ] ; if ( ! listener ) { throw new Error ( `Process ${ id } cannot execute ${ method } - method  not found.` ) ; } return listener ( data ) ; } public subscribe ( channel , listener ) { this . channels [ channel ] = listener ; } public unsubscribe ( channel ) { delete this . channels [ channel ] ; } public publish ( channel , data ) { const listener = this . channels [ channel ] ; return listener && listener ( data ) ; } public close ( ) { return ; } }