rpc/dist/index.js

25 lines
641 B
JavaScript
Raw Normal View History

2022-11-14 16:09:45 +00:00
// @ts-ignore
import ProtomuxRPC from "protomux-rpc";
// @ts-ignore
import c from "compact-encoding";
import b4a from "b4a";
const ID = b4a.from("lumeweb");
export default class RPC extends ProtomuxRPC {
constructor(stream, options = {}) {
options = {
...{
id: ID,
2022-11-27 23:23:08 +00:00
valueEncoding: c.json,
},
...options,
2022-11-14 16:09:45 +00:00
};
super(stream, options);
}
2022-11-27 23:23:08 +00:00
async request(method, value = b4a.from(""), options = {}) {
if (!b4a.isBuffer(value)) {
value = b4a.from(value);
}
return super.request(method, value, options);
}
2022-11-14 16:09:45 +00:00
}