@jeffriggle/ipc-bridge-server
Communicate bridge server for electrons ipc
Last updated a year ago by jeffriggle .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @jeffriggle/ipc-bridge-server 
SYNC missed versions from official npm registry.

ipc-bridge-server

This is a library intended to be used as a wrapper around Electron's IPC Main. This is ment to be used in conjuction with ipc-bridge-client (render process).

Installation

$ install @jeffriggle/ipc-bridge-server

Usage

Starting the Server

Once you are ready to start accepting messages you can turn the messaging on by using the start function.

let {start} = require('@jeffriggle/ipc-bridge-server')

// Some required startup logic
start();

Registering an event.

In order to allow the client to communicate you need to expose events that the client can communicate with you over. These are simple request response hookups.

let {registerEvent} = require('@jeffriggle/ipc-bridge-server')

// Some required startup logic
registerEvent('customeventname', (event, data) => {
    // Logic to handle request
    // Event is the sender while data is whatever the client passed to you.
    // You can return any value here or no value. 
    // This will be given as the result for the client side promise
    return {};
});

Broadcasting an event.

In some cases a client can subscribe to an event. In order to send a message to all clients that are listening for these events you can use a broadcast.

let {broadcast} = require('@jeffriggle/ipc-bridge-server')

// The data to broadcast
let data = {};
broadcast('customeventname', data);

Example

Some simple examples of this can be found at ipc-bridge

License

ipc-bridge-server is released under MIT

Current Tags

  • 1.0.5                                ...           latest (a year ago)

6 Versions

  • 1.0.5                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 2
Dependencies (3)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |