https://github.com/lwdgit/simple-ipc
simple ipc...
https://github.com/lwdgit/simple-ipc
ipc
Last synced: 4 months ago
JSON representation
simple ipc...
- Host: GitHub
- URL: https://github.com/lwdgit/simple-ipc
- Owner: lwdgit
- License: mit
- Created: 2017-02-26T09:28:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-07T07:22:54.000Z (over 8 years ago)
- Last Synced: 2025-01-04T19:11:55.717Z (6 months ago)
- Topics: ipc
- Language: JavaScript
- Size: 29.3 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# simple-ipc
> Simplest way to handle inner process communication.
## Usage
```
//client.js
import { Client } from 'simple-ipc';
new Client({
events: {
'connect': function() {
console.log('connect');
},
'close': function() {
console.log('client close');
},
'mymsg': function(msg) {
console.log('receive', msg);
}
}
});
``````
//server.js
import { Server } from 'simple-ipc';
new Server({
events: {
'connect': function() {
this.emit('mymsg', 'hello');
},
'close': function() {
console.log('detect close');
}
}
})
```## API
* Server
* `constructor({events: {}})` default events listener
* `on(event, fn)` listen client msg
* `emit(event, msg)` broadcast msg to clients* Client
* `constructor({events: {}})` default events listener
* `on(event, fn)` listen server broadcast
* `emit(event, msg)` emit msg to server