1 Star 0 Fork 0

白一梓 / local-rpc

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
readme.md

lrpc

项目源码摘自淘宝开源项目 pandora ,pandora 是一个淘宝开源的进程管理工具,里面进程间通信的模块很具有参考意义,所以将其单独分离出来做成一个项目。

安装

npm install lrpc --save

使用示例

const assert = require('assert');
const {Server,Client,util} = require('lrpc');
const msg = {
    name: 'midway-messenger',
};
const action = 'midway-messenger-action';
const sockPath = util.getRandomSocketPath();
const server = new Server({sockPath});
const client = new Client({sockPath});
new Promise(function(resolve) {
    client.ready(function() {
        resolve(client);
    });
}).then(function() {
    server.broadcast(action, msg);
    return new Promise(function(resolve) {
        client.on(action, (message) => {
            assert(message.name === msg.name);
            resolve();
        });
    });
}).then(function() {
    console.info('成功');
    assert(true);
}).catch(function() {
    assert(false);
});

在线文档

Comments ( 0 )

Sign in for post a comment

About

Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
1
https://git.oschina.net/yunnysunny/local-rpc.git
git@git.oschina.net:yunnysunny/local-rpc.git
yunnysunny
local-rpc
local-rpc
master

Search