{"id":21029428,"url":"https://github.com/michaelvasseur/electron-ipc-bus","last_synced_at":"2025-05-15T11:31:56.143Z","repository":{"id":57159427,"uuid":"75072230","full_name":"MichaelVasseur/electron-ipc-bus","owner":"MichaelVasseur","description":"An IPC bus for Electron.","archived":false,"fork":false,"pushed_at":"2018-11-20T21:53:12.000Z","size":989,"stargazers_count":23,"open_issues_count":0,"forks_count":17,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-26T09:48:41.945Z","etag":null,"topics":["electron","ipc","rpc","sandbox"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MichaelVasseur.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-29T10:53:04.000Z","updated_at":"2022-02-19T01:47:49.000Z","dependencies_parsed_at":"2022-09-08T11:03:41.252Z","dependency_job_id":null,"html_url":"https://github.com/MichaelVasseur/electron-ipc-bus","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelVasseur%2Felectron-ipc-bus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelVasseur%2Felectron-ipc-bus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelVasseur%2Felectron-ipc-bus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelVasseur%2Felectron-ipc-bus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MichaelVasseur","download_url":"https://codeload.github.com/MichaelVasseur/electron-ipc-bus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254330721,"owners_count":22053034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["electron","ipc","rpc","sandbox"],"created_at":"2024-11-19T12:12:22.631Z","updated_at":"2025-05-15T11:31:54.148Z","avatar_url":"https://github.com/MichaelVasseur.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# electron-ipc-bus\nA safe IPC (Inter-Process Communication) bus for applications built on Electron. \n\nThis bus offers a common API for exchanging data between any Electron process : Node, Master and Renderer instances.\n\n\n# Features\n* Publish/Subscribe oriented API\n* Works with sandboxed renderer process\n* Support for renderer affinity (several webpages hosted in the same renderer process)\n* Remote calls/events and pending messages management with Services\n\n# Installation\n```Batchfile\nnpm install electron-ipc-bus\n```\n\nDependencies\n* https://github.com/oleics/node-easy-ipc\n* https://github.com/pkrumins/node-lazy\n* https://github.com/defunctzombie/node-uuid\n* http://electron.atom.io/\n* http://nodejs.org/\n\n\n# Technical Overview\n\n## Objective\n![Electron's processes](https://raw.githubusercontent.com/MichaelVasseur/electron-ipc-bus/Doc_Update/doc/electron_processes.svg)\n\n\n# Usage\n\n```js\n// Load modules\nconst ipcBusModule = require(\"electron-ipc-bus\");\nconst electronApp = require('electron').app;\n\n// Configuration\nconst ipcBusPath = 50494;\n// const ipcBusPath = '/myfavorite/path';\n\n// Startup\nelectronApp.on('ready', function () {\n    // Create broker\n    const ipcBusBroker = ipcBusModule.CreateIpcBusBroker(ipcBusPath);\n    // Start broker\n    ipcBusBroker.start()\n        .then((msg) =\u003e {\n            console.log('IpcBusBroker started');\n\n            // Create bridge\n            const ipcBusBridge = ipcBusModule.CreateIpcBusBridge(ipcBusPath);\n            // Start bridge\n            ipcBusBridge.start()\n                .then((msg) =\u003e {\n                    console.log('IpcBusBridge started');\n\n                    // Create clients\n                    const ipcBusClient1 = ipcBusModule.CreateIpcBusClient(ipcBusPath);\n                    const ipcBusClient2 = ipcBusModule.CreateIpcBusClient(ipcBusPath);\n                    Promise.all([ipcBusClient1.connect('client1'), ipcBusClient2.connect('client2')])\n                        .then((msg) =\u003e {\n                            // Chatting on channel 'greeting'\n                            ipcBusClient1.addListener('greeting', (ipcBusEvent, greetingMsg) =\u003e {\n                                if (ipcBusEvent.request) {\n                                    ipcBusEvent.request.resolve('thanks to you, dear #' + ipcBusEvent.sender.name);\n                                }\n                                else {\n                                    ipcBusClient1.send('greeting-reply', 'thanks to all listeners')\n                                }\n                                console.log(ipcBusClient1.peer.name + ' received ' + ipcBusEvent.channel + ':' + greetingMsg);\n                            });\n\n                            ipcBusClient2.addListener('greeting', (ipcBusEvent, greetingMsg) =\u003e {\n                                if (ipcBusEvent.request) {\n                                    ipcBusEvent.request.resolve('thanks to you, dear #' + ipcBusEvent.sender.name);\n                                }\n                                else {\n                                    ipcBusClient2.send('greeting-reply', 'thanks to all listeners')\n                                }\n                                console.log(ipcBusClient2.peer.name + ' received ' + ipcBusEvent.channel + ':' + greetingMsg);\n                            });\n\n                            ipcBusClient1.addListener('greeting-reply', (ipcBusEvent, greetingReplyMsg) =\u003e {\n                                console.log(greetingReplyMsg);\n                                console.log(ipcBusClient1.peer.name + ' received ' + ipcBusEvent.channel + ':' + greetingReplyMsg);\n                            });\n\n                            ipcBusClient2.send('greeting', 'hello everyone!');\n\n                            ipcBusClient2.request('greeting', 'hello partner!')\n                                .then((ipcBusRequestResponse) =\u003e {\n                                    console.log(JSON.stringify(ipcBusRequestResponse.event.sender) + ' replied ' + ipcBusRequestResponse.payload);\n                                })\n                                .catch((err) =\u003e {\n                                    console.log('I have no friend :-(');\n                                });\n\n                            ipcBusClient1.request(1000, 'greeting', 'hello partner, please answer within 1sec!')\n                                .then((ipcBusRequestResponse) =\u003e {\n                                    console.log(JSON.stringify(ipcBusRequestResponse.event.sender) + ' replied ' + ipcBusRequestResponse.payload);\n                                })\n                                .catch((err) =\u003e {\n                                    console.log('I have no friend :-(');\n                                });\n                        });\n                });\n        });\n});\n```\n\n# IpcBusBroker\nDispatching of Node messages is managed by a broker. You can have only one single Broker for the whole application.\nThe broker can be instanciated in a node process or in the master process (not in renderer processes).\nFor performance purpose, it is better to instanciate the broker in an independent node process.\n\n## Interface\n```ts\ninterface IpcBusBroker {\n    start(timeoutDelay?: number): Promise\u003cstring\u003e;\n    stop(): void;\n    queryState(): Object;\n    isServiceAvailable(serviceName: string): boolean;\n}\n```\n## Initialization of the Broker (in a node process)\n\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\nconst ipcBusBroker = ipcBusModule.CreateIpcBusBroker([busPath]);\n```\n\nThe ***require()*** call loads the module and CreateIpcBusBroker setups the broker with the ***busPath***.\nIf ***busPath*** is not specified, the framework tries to get it from the command line with switch ***--bus-path***.\n \nExample with ***busPath*** set by code\n\n```js\n// Socket path\nconst ipcBusBroker = ipcBusModule.CreateIpcBusBroker('/my-ipc-bus-path');\n```\n\n```js\n// Port number\nconst ipcBusBroker = ipcBusModule.CreateIpcBusBroker(58666);\n```\n\nExample with ***busPath*** set by command line:\n```Batchfile\nelectron.exe --bus-path=58666\n```\n    \n```js\nconst ipcBusBroker = ipcBusModule.CreateIpcBusBroker();\n```\n\n## Methods\n\n### start([timeoutDelay]) : Promise \u003c string \u003e\n- ***timeoutDelay*** : number (milliseconds)\n\n```js\nipcBusBroker.start() \n    .then((msg) =\u003e console.log(msg))\n    .catch((err) =\u003e console.log(err))\n````\n\nStarts the broker dispatcher.\nIf succeeded the value of ***msg*** is 'started' (do not rely on it, subject to change). \nIf failed (timeout or any other internal error), ***err*** contains the error message.\n\n### stop()\n\n```js\nipcBusBroker.stop() \n```\n\n### queryState() - for debugging purpose only\n\n```js\nvar queryState = ipcBusBroker.queryState() \n````\n\nReturns the list of pair \u003cchannel, peer\u003e subscriptions. Format may change from one version to another.\nThis information can be retrieved from an IpcBusClient through the channel : /electron-ipc-bus/queryState\n\n### isServiceAvailable(serviceName): boolean \n- ***serviceName***: string\n\n```js\nipcBusBroker.isServiceAvailable('mySettings') \n````\n\nTest if a service is started.\nThis information can be retrieved from an IpcBusClient through the channel : /electron-ipc-bus/serviceAvailable\n\n\n# IpcBusBridge\nDispatching of Renderer messages is managed by a bridge. You can have only one single bridge for the whole application.\nThe bridge must be instanciated in the master process only. Without this bridge, Renderer and Node processes are not able to dialog.\n\n## Interface\n```ts\ninterface IpcBusBridge {\n    start(timeoutDelay?: number): Promise\u003cstring\u003e;\n    stop(): void;\n}\n```\n## Initialization of the Bridge (in the master process)\n\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\nconst ipcBusBridge = ipcBusModule.CreateIpcBusBridge([busPath]);\n```\n\nThe ***require()*** call loads the module and CreateIpcBusBridge setups the bridge with the ***busPath***.\nIf ***busPath*** is not specified, the framework tries to get it from the command line with switch ***--bus-path***.\n \nExample with ***busPath*** set by code\n\n```js\n// Socket path\nconst ipcBusBridge = ipcBusModule.CreateIpcBusBridge('/my-ipc-bus-path');\n```\n\n```js\n// Port number\nconst ipcBusBridge = ipcBusModule.CreateIpcBusBridge(58666);\n```\n\nExample with ***busPath*** set by command line:\n```Batchfile\nelectron.exe --bus-path=58666\n```\n    \n```js\nconst ipcBusBridge = ipcBusModule.CreateIpcBusBridge();\n```\n\n## Methods\n\n### start([timeoutDelay]) : Promise \u003c string \u003e\n- ***timeoutDelay*** : number (milliseconds)\n\n```js\nipcBusBridge.start() \n    .then((msg) =\u003e console.log(msg))\n    .catch((err) =\u003e console.log(err))\n````\n\nStarts the bridge dispatcher.\nIf succeeded the value of ***msg*** is 'started' (do not rely on it, subject to change). \nIf failed (timeout or any other internal error), ***err*** contains the error message.\n\n### stop()\n\n```js\nipcBusBridge.stop() \n```\n\n\n# IpcBusClient\nThe ***IpcBusClient*** is an instance of the ***EventEmitter*** class.\n\nWhen you register a callback to a specified channel. Each time a message is received on this channel, the callback is called.\nThe callback must follow the ***IpcBusListener*** signature (see below).\n\nOnly one ***IpcBusClient*** per Process/Renderer is created. If you ask for more, the same instance will be returned.\n\n## Interface\n```ts\ninterface IpcBusClient extends events.EventEmitter {\n    readonly peerName: string;\n    connect(timeoutDelayOrPeerName?: number | string, peerName?: string): Promise\u003cstring\u003e;\n    close(): void;\n    send(channel: string, ...args: any[]): void;\n    request(timeoutDelayOrChannel: number | string, ...args: any[]): Promise\u003cIpcBusRequestResponse\u003e;\n\n    // EventEmitter overriden API\n    addListener(channel: string, listener: IpcBusListener): this;\n    removeListener(channel: string, listener: IpcBusListener): this;\n    on(channel: string, listener: IpcBusListener): this;\n    once(channel: string, listener: IpcBusListener): this;\n    off(channel: string, listener: IpcBusListener): this;\n\n    // Added in Node 6...\n    prependListener(channel: string, listener: IpcBusListener): this;\n    prependOnceListener(channel: string, listener: IpcBusListener): this;\n}\n```\n\n## Initialization in the Main/Browser Node process\n\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\nconst ipcBus = ipcBusModule.CreateIpcBusClient([busPath]);\n````\n\nThe ***require()*** call loads the module. CreateIpcBus setups the client with the ***busPath*** that was used to start the broker.\nIf ***busPath*** is not specified, the framework tries to get it from the command line with switch ***--bus-path***.\n \nExample with ***busPath*** set by code:\n```js\nconst ipcBus = ipcBusModule.CreateIpcBusClient('/my-ipc-bus-path');\n```\n\nExample with ***busPath*** set by command line:\n```\nelectron.exe --bus-path='/my-ipc-bus-path'\n```\n```js    \nconst ipcBus = ipcBusModule.CreateIpcBusClient();\n```\n\n## Initialization in a Node single process\n \nExample with ***busPath*** set by code:\n```js\nconst ipcBus = ipcBusModule.CreateIpcBusClient('/my-ipc-bus-path');\n```\nExample with ***busPath*** set by command line:\n```\nelectron.exe --bus-path='/my-ipc-bus-path'\n```\n```js \nconst ipcBus = ipcBusModule.CreateIpcBusClient();\n```\n## Initialization in a Renderer process (either sandboxed or not)\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\nconst ipcBus = ipcBusModule.CreateIpcBusClient();\n```\n\nNOTE: If the renderer is running in sandboxed mode, the above code must be run from the ***BrowserWindow***'s preload script (browserify -o BundledBrowserWindowPreload.js ***-x electron*** BrowserWindowPreload.js). \nOtherwise, the Electron's ipcRenderer is not accessible and the client cannot work.\nUse the code below to make the client accessible to the the Web page scripts.\n```js\nwindow.ipcBus = require('electron-ipc-bus').CreateIpcBusClient();\n```\n\n## Property\n\n### peer\nFor debugging purpose, each ***IpcBusClient*** is identified by a peer.\n```js\ninterface IpcBusProcess {\n    type: string;\n    pid: number;\n}\n\ninterface IpcBusPeer {\n    name: string;\n    process: IpcBusProcess;\n}\n```\nit contains the name of the peer, this name can be changed during the connection.\nit contains the process context of the peer : type and pid.\n- type: Master, pid : Process Id\n- type: Node, pid: Process Id\n- type: Renderer, pid: WebContents Id\n\n## Connectivity Methods\n\n### connect([timeoutDelayOrPeerName?: number | string[, peerName?: string]]) : Promise \u003c string \u003e\n- ***timeoutDelayOrPeerName*** = timeoutDelay: number (milliseconds) | peerName: string\n- ***peerName*** = peerName: string\n\nBasic usage\n```js\nipcBus.connect().then((eventName) =\u003e console.log(\"Connected to Ipc bus !\"))\n```\n\nProvide a timeout\n```js\nipcBus.connect(2000).then((eventName) =\u003e console.log(\"Connected to Ipc bus !\"))\n```\n\nProvide a peer name\n```js\nipcBus.connect('client2').then((eventName) =\u003e console.log(\"Connected to Ipc bus !\"))\n```\n\nProvide all options\n```js\nipcBus.connect(2000, 'client2').then((eventName) =\u003e console.log(\"Connected to Ipc bus !\"))\n```\n\nFor a bus in a renderer, it fails if the Bridge is not started else it fails if the Broker is not started.\nMost of the functions below will fail if the connection is not established (you have to wait for the connect promise).\n\n### close()\n```js\nipcBus.close()\n```\n\n### addListener(channel, listener)\n- ***channel***: string\n- ***listener***: IpcBusListener\n\nListens to ***channel***, when a new message arrives ***listener*** would be called with listener(event, args...).\n\nNOTE: ***on***, ***prependListener***, ***once*** and ***prependOnceListener*** methods are supported as well\n\n### removeListener(channel, listener)\n- ***channel***: string\n- ***listener***: IpcBusListener\n\nRemoves the specified ***listener*** from the listeners array for the specified ***channel***.\n\nNOTE: ***off*** method is supported as well\n\n### removeAllListeners([channel])\n***channel***: String (optional)\n\nRemoves all listeners, or those of the specified ***channel***.\n\n## IpcBusListener(event, ...args) callback\n- ***event***: IpcBusEvent\n- ***...args***: any[]): void\n\nThe first parameter of the callback is always an event which contains the channel and the origin of the message (sender).\n\n```js\nfunction HelloHandler(ipcBusEvent, content) {\n    console.log(\"Received '\" + content + \"' on channel '\" + ipcBusEvent.channel +\"' from #\" + ipcBusEvent.sender.peerName)\n}\nipcBus.on(\"Hello!\", HelloHandler)\n```\n\n## Posting Methods\n### send(channel [, ...args])\n- ***channel***: string\n- ***...args***: any[]\n\nSends a message asynchronously via ***channel***, you can also send arbitrary arguments. \nArguments will be serialized in JSON internally and hence no functions or prototype chain will be included.\n\n```js\nipcBus.send(\"Hello!\", { name: \"My age !\"}, \"is\", 10)\n```\n\n### request(timeoutDelayOrChannel: number | string, ...args: any[]): Promise \u003c IpcBusRequestResponse \u003e\n- ***timeoutDelayOrChannel*** = timeoutDelay: number (milliseconds) | channel: string\n- ***...args***: any[]\n\nSends a request message on specified ***channel***. The returned Promise is settled when a result is available.\n\nThis function can be used in 2 ways :\n* request(timeoutDelay: number, channel: string, ...args: any[]): Promise \u003c IpcBusRequestResponse \u003e\nif the first parameter is a number, this parameter ***timeoutDelay*** defines how much time we're waiting for the response. The 2nd parameter must be the channel.\n\n* request(channel: string, ...args: any[]): Promise \u003c IpcBusRequestResponse \u003e\nThe ***channel*** is the... channel, a default timeout delay is applied.\n\nThe Promise provides an ***IpcBusRequestResponse*** object:\n```ts\ninterface IpcBusRequestResponse {\n    event: IpcBusEvent;\n    payload?: Object | string;\n    err?: string;\n}\n```\n\n```js\nipcBus.request(\"compute\", \"2*PI*9\")\n    .then(ipcBusRequestResponse) {\n        console.log(\"channel = \" + ipcBusRequestResponse.event.channel + \", response = \" + ipcBusRequestResponse.payload + \", from = \" + ipcBusRequestResponse.event.sender.peerName);\n     }\n     .catch(ipcBusRequestResponse) {\n        console.log(\"err = \" + ipcBusRequestResponse.err);\n     }\n```\n\nWith timeout\n```js\nipcBus.request(2000, \"compute\", \"2*PI*9\")\n...\n```\n\n## IpcBusEvent object\n```ts\ninterface IpcBusEvent {\n    channel: string;\n    sender: IpcBusSender {\n        peerName: string;\n    };\n    request?: IpcBusRequest {\n        resolve(payload: Object | string): void;\n        reject(err: string): void;\n    };\n}\n```\nThe event object passed to the listener has the following properties:\n### event.channel: string\n***channel*** delivering the message\n\n### event.sender.peerName: string\n***peerName*** of the sender\n\n### event.request [optional]: IpcBusRequest\nIf present, the message is a request.\nListener can resolve the request by calling ***event.request.resolve()*** with the response or can reject the request by calling ***event.request.reject()*** with an error message.\n\n\n# IpcBusService\nThe ***IpcBusService*** creates an IPC endpoint that can be requested via remote calls and send events.\n\n## Interface\n```ts\ninterface IpcBusService {\n    start(): void;\n    stop(): void;\n    registerCallHandler(name: string, handler: IpcBusServiceCallHandler): void;\n    sendEvent(eventName: string, ...args: any[]): void;\n}\n```\n\n## IpcBusServiceCall\nMessage sent to a service to execute a remote call.\n```ts\ninterface IpcBusServiceCall {\n    handlerName: string;\n    args: any[];\n}\n```\n\n## IpcBusServiceCallHandler\nPrototype of a method that will be executed to handle a service's call.\n```ts\ninterface IpcBusServiceCallHandler {\n    (call: IpcBusServiceCall, request: IpcBusRequest): void;\n}\n```\n\n## Creation (without an outer implementation)\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\n...\n// ipcBusClient is a connected instance of IpcBusClient\nconst ipcMyService = ipcBusModule.CreateIpcBusService(ipcBusClient, 'myService');\n```\n\n## Creation (with an outer instance)\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\n...\nconst myOuterServiceInstance = {};\nmyOuterServiceInstance.test = () =\u003e { return 'This is a test'; };\n...\n// ipcBusClient is a connected instance of IpcBusClient\nconst ipcMyService = ipcBusModule.CreateIpcBusService(ipcBusClient, 'myService', myOuterServiceInstance);\n```\nNOTE : This constructor will automatically register all methods of ***myOuterServiceImpl*** as call handlers using ***registerCallHandler()***.\n\n## Methods\n\n### start(): void\nThis makes the service to listen and serve incoming remote calls.\nThe service also sends the ***IPCBUS_SERVICE_EVENT_START*** event.\nNOTE : If an outerrouter service's instance has been specified at construction time, ***start()*** will overload its This method will overload\n\n### stop(): void\nThis makes the service to stop listen and serve incoming remote calls.\nThe service also sends the ***IPCBUS_SERVICE_EVENT_STOP*** event.\n\n### registerCallHandler(name, handler): void\n- ***name***: string\n- ***handler***: IpcBusServiceCallHandler\nThis sets the function that will be executed to serve the specified remote call.\nAs this is run in the context of a promise, the function must call either request.resolve()\nor request.reject() to fulfill the promise.\n```js\nipcMyService.registerCallHandler('getCurrentTime', (call, request) =\u003e {\n                        try {                        {\n                            request.resolve(new Date().getTime());\n                        } catch(e) {\n                            request.reject(e);\n                        }\n                    });\n```\n\n### sendEvent(name, ...args): void\n- ***name***: string\n- ***args***: any[]\nThis sends a service event message.\n```js\nipcMyService.sendEvent('timeChanged', new Date().getTime());\n```\n\n\n# IpcBusServiceProxy\nThe ***IpcBusServiceProxy*** creates an IPC endpoint that can be used to execute calls on a service and listen its events.\n\n## Interface\n```ts\ninterface IpcBusServiceProxy extends events.EventEmitter {\n    readonly isStarted: boolean;\n\n    getStatus(): Promise\u003cServiceStatus\u003e;\n    call\u003cT\u003e(handlerName: string, ...args: any[]): Promise\u003cT\u003e;\n    getWrapper\u003cT\u003e(): T;\n```\n\n## IpcBusServiceEvent\nMessage sent to a service's proxy to trigger the code associated to this event.\n```ts\ninterface IpcBusServiceEvent {\n    eventName: string;\n    args: any[];\n}\n```\n\n## IpcBusServiceEventHandler\nPrototype of a method that will be executed to handle a service's call.\n```ts\ninterface IpcBusServiceEventHandler {\n    (event: IpcBusServiceEvent): void;\n}\n```\n\n## Creation\n```js\nconst ipcBusModule = require(\"electron-ipc-bus\");\n...\n// ipcBusClient is a connected instance of IpcBusClient\nconst ipcMyServiceProxy = ipcBusModule.CreateIpcBusServiceProxy(ipcBusClient, 'myService', 2000); // 2000 ms for call timeout (default is 1000 ms)\n```\n\n## Properties\n\n### isAvailable: boolean\nAvailability of the associated service (available means that the service is started).\n\n## Methods\n\n### checkAvailability(): Promise\u003c boolean \u003e\nThis asynchronously requests the service availability to the Broker.\n```js\nipcMyServiceProxy.checkAvailability()\n        .then(\n            (availability) =\u003e console.log(`MyService availability = ${availability}`),\n            (err) =\u003e console.log(`Failed to get MyService availability (${err})`));\n```\n\n### call\u003cT\u003e(handlerName: string, timeout: number, ...args: any[]): Promise\u003c T \u003e\n- ***handlerName***: string\n- ***timeout***: number\n- ***args***: any[]\nThis sends a service event message.\n```js\nipcMyServiceProxy.call('getCurrentTime')\n        .then(\n            (currentTime) =\u003e console.log(`Current Time = ${currentTime}`),\n            (err) =\u003e console.log(`Failed to get current time : ${err}`));\n```\n\n### EventEmitter interface ###\nThis allow to handle events emitted by remote RPC service. Please refers to the EventEmitter class documentation for more information.\n- addListener(event: string, listener: IpcBusServiceEventHandler): this;\n- removeListener(event: string, listener: IpcBusServiceEventHandler): this;\n- on(event: string, listener: IpcBusServiceEventHandler): this;\n- once(event: string, listener: IpcBusServiceEventHandler): this;\n- off(event: string, listener: IpcBusServiceEventHandler): this;\n- removeAllListeners(event?: string): this;\n- prependListener(event: string, listener: IpcBusServiceEventHandler): this;\n- prependOnceListener(event: string, listener: IpcBusServiceEventHandler): this;\n\nThe wrapper implements EventEmitter as well. If the interface of the service emits an event it will be receiced by the wrapper of the proxy.\n\n# Test application\nThe test-app folder contains all sources of the testing application.\n\nNOTE: This folder is not packaged by NPM.\n\nTo build the application:\n```\ncd examples\ncd test-app\nnpm install\nnpm run build\n```\n\nTo run the application:\n```\nnpm run start\n```\n\nTo run the application in sandboxed mode:\n```\nnpm run start-sandboxed\n```\n\n\n# Possible enhancements\n* Support several brokers each with its own buspath in order to distribute the traffic load.\n* Add an optional spy for debugging purpose\n\n# MIT License\n\nCopyright (c) 2017 Michael Vasseur and Emmanuel Kimmerlin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelvasseur%2Felectron-ipc-bus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelvasseur%2Felectron-ipc-bus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelvasseur%2Felectron-ipc-bus/lists"}