1.1.1 • Published 3 years ago

set-sail-rpc-node v1.1.1

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

自定义RPC协议 Node.JS版本

通信协议

输入图片说明

通信流程

输入图片说明

使用:

1.引入依赖:

npm install set-sail-rpc-node@1.0.4 --save

2.RPC Client端使用(调用Java):

import RpcClient from "set-sail-rpc-node/RpcClient.mjs";

const rpcClient = new RpcClient("192.168.1.150:20883");
(async () => {
    const result = await rpcClient.invoke("com.cupiday.xinvite.gateway.business.service.IHello", "sayHello", {name: "haha"});
    console.log(result);
})();

3.RPC Server端使用:

import RpcServer from "set-sail-rpc-node/RpcServer.mjs";
import log from "../utils/Log4js.mjs";
import ConfigUtil from "../utils/ConfigUtil.mjs";
import {abnormalLogin} from "./OfflineEventService.mjs";

const server_config = ConfigUtil.getConfig("server_config");

class RPCService {
    start() {
        const rpcServer = new RpcServer(server_config.rpcServer.hostname, server_config.rpcServer.port);
        rpcServer
            .registry("OfflineEventService", "abnormalLogin", abnormalLogin)
            .start();
        log.info(`rpc server listen ${server_config.rpcServer.port}`);
    }
}

export default new RPCService();
1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago