2.0.7 • Published 3 years ago
icebreaker-rpc v2.0.7
icebreaker-rpc
RPC API based on icebreaker-peer and muxrpc
Install
npm install --save icebreaker-rpc
Example
const { Server, Connect, Async, Sync, AsyncPromise, Source, Sink, Local, KeyPair, _ } = require('./')
const alice = KeyPair.generate()
const bob = KeyPair.generate()
const api = Local()
api.helloAsync = Async((text, cb) => { cb(false, text + " world") }, "string")
api.helloPromise = AsyncPromise((text) => {
return new Promise((resolve, reject) => { resolve(text + ' world') }, "string")
})
api.helloSink = Sink((cb) => { return _.drain((item) => { console.log("hello " + item) }, cb) })
// create Server
let server = Server(api, { keys: alice, appKey: "icebreaker@example" })
server.listen('shs+tcp://127.0.0.1:8080')
_(
server,
server.on({
ready: (e) => {
// create client connection
Connect(e.address[0], null, { keys: bob, appKey: "icebreaker@example" }, (err, connection) => {
console.log("hallo", connection)
connection.peer.helloAsync("hello", (err, data) => {
console.log(err, data)
connection.peer.helloPromise("hello").then((data) => {
console.log(data)
_("sink", api.helloSink(function () {
server.end()
}))
})
})
})
},
end: () => { console.log("end") }
}))
License
MIT
2.0.7
3 years ago
2.0.3
3 years ago
2.0.2
3 years ago
2.0.5
3 years ago
2.0.4
3 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.5.9
3 years ago
1.5.8
3 years ago
1.5.7
3 years ago
1.5.6
3 years ago
1.5.5
3 years ago
1.5.4
3 years ago
1.5.3
3 years ago
1.5.2
3 years ago
1.5.1
3 years ago
1.5.0
4 years ago
1.4.1
4 years ago
1.4.0
5 years ago
1.3.3
5 years ago
1.3.2
5 years ago
1.3.1
5 years ago
1.3.0
5 years ago
1.2.0
5 years ago
1.1.3
5 years ago
1.1.2
5 years ago
1.1.1
5 years ago
1.1.0
5 years ago
1.0.25
5 years ago
1.0.23
5 years ago
1.0.22
5 years ago
1.0.20
5 years ago
1.0.19
5 years ago
1.0.18
5 years ago
1.0.17
5 years ago
1.0.16
5 years ago
1.0.15
5 years ago
1.0.14
5 years ago
1.0.13
5 years ago
1.0.12
5 years ago
1.0.11
5 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 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
0.3.1
9 years ago
0.3.0
9 years ago
0.2.0
9 years ago
0.1.1
9 years ago
0.1.0
9 years ago