import JsonRPC from '@genee/json-rpc'
const rpc = new JsonRPC(data => {
// send your data with your customized function
}, {
// logger?: console // you may customize your own logger
})
rpc.receive(data) // process the data you received
rpc.on('xxx', () => {})
await rpc.call('xxx', params)
await rpc.notify('xxx', params)
rpc.setReady(false);
rpc.setReady(true);
// get referenced functions and objects
const { functions, objects } = rpc.stat();
import JsonRPC, { Smartify } from '@genee/json-rpc';
const SmartRPC = Smaritfy(JsonRPC);
const rpc = new SmartRPC(data => {
// do your sending
})
rpc.setReady(false);
rpc.setReady(true);
rpc.whenReady(() => {
// DO SOMEHTING WHEN RPC READY
});
rpc.whenNotReady(() => {
// DO SOMEHTING WHEN RPC NOT READY
})
rpc.receive(data); // process data you received
await rpc.Namespace1.Namespace2.Method1('hello'); // == rpc.call('Namespace1.Namespace2.Method1', ['hello'])