1.0.7 • Published 4 years ago

base-easy-jsonrpc v1.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
4 years ago

easy-jsonrpc

项目介绍

基于promise封装的jsonrpc库

使用范例

        const server = new RpcServer();
        server.onNotify("success", (params, router) => {
            router.redirect("error");
        });
        server.onNotify("error", () => {
            console.log("notify----error");
        });
        server.onCall("login", (params, router) => {
            router.redirect("loginError");
            //return true;
            //return {token:"133"};
            //throw error;
        });
        server.onCall("loginError", (params, router) => {
            return true;
        });
        server.onCall(/^login/, () => {
            return "login rexge";
        });


       const client = new RpcClient({timeout: 3000}, {
            send: (data) => {
                this.server.onClientMessage({
                    send: (data) => {
                        client.onServerMessage(data);
                    }
                }, data)
            }
        });
       const result = await client.call("login",{},1000);
       console.log(result);

       client.notify("success");
1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago