4.0.7 • Published 7 days ago

@peerbit/rpc v4.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
7 days ago

RPC

This module contains a communication protocol for generic request-and-response communication. This module can be used as a component in other modules. Documents, DString for examples

How it works

@variant("hello")
class Hello {
    
    // add payload properties here
    constructor() {
       
    }
}

@variant("world")
class World {
    
    // add payload properties here
    constructor() {
       
    }
}

@variant("rpc-test")
class RPCTest extends Program {

    @field({ type: RPC })
    rpc: RPC<Hello, World>;

    async setup(): Promise<void> {
        await this.rpc.setup({
            responseType: Hello,
            queryType: World,
            context: this,
            responseHandler: (resp, from) => {
                return resp;
            },
        });
    }
}

// later (assume that some other peers also opens the RPCTest program)
const peer = await Peerbit.create ()
const rpcTest = peer.open(new RPCTest());

await rpcTest.rpc.request( new Hello(), (resp) => { console.log(resp)  })

Visualized

See Document store and Clock Service as implementation examples.

4.0.7-aa577a5

7 days ago

4.0.7-0691c73

7 days ago

4.0.7-218a5bb

7 days ago

4.0.7-efee9d3

1 month ago

4.0.7-a4f88b6

1 month ago

4.0.7-a9206a8

1 month ago

4.0.7

2 months ago

4.0.6

3 months ago

4.0.5

3 months ago

4.0.4

3 months ago

4.0.3

3 months ago

4.0.2

3 months ago

4.0.1

3 months ago

4.0.0

3 months ago

3.0.25

3 months ago

3.0.23

3 months ago

3.0.24

3 months ago

3.0.21

4 months ago

3.0.22

4 months ago

3.0.20

4 months ago

3.0.18

4 months ago

3.0.19

4 months ago

3.0.16

4 months ago

3.0.17

4 months ago

3.0.15

4 months ago

3.0.14

4 months ago

3.0.13

4 months ago

3.0.12

4 months ago

3.0.11

4 months ago

3.0.10

4 months ago

3.0.9

4 months ago

3.0.8

4 months ago

3.0.7

4 months ago

3.0.4

4 months ago

3.0.6

4 months ago

3.0.5

4 months ago

3.0.3

4 months ago

3.0.2

4 months ago

3.0.1

4 months ago

2.1.17

8 months ago

2.1.16

8 months ago

2.1.15

8 months ago

2.1.14

8 months ago

2.1.13

8 months ago

2.1.12

8 months ago

2.1.11

8 months ago

2.1.10

8 months ago

2.1.9

8 months ago

2.1.8

8 months ago

2.1.7

8 months ago

2.1.6

8 months ago

2.1.5

8 months ago

2.1.4

8 months ago

2.1.3

9 months ago

2.1.2

9 months ago

2.1.1

9 months ago

2.1.0

9 months ago

2.0.1

10 months ago

2.0.0

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.12

10 months ago

1.0.11

10 months ago

1.0.10

10 months ago

1.0.9

10 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.2

11 months ago