Arc RPC
Asynchronous Remote Classes make RPC simple
How does it work
Arc RPC allows you to remotely call functions on other processes or even other hardware using these few main concepts
- Ability to wrap existing class instances
- Mock that acts like the remote class
- Bi-directional
- Protocol agnostic
How to use it
Here is a basic example of using RPC with socket.io
client.js
let ClientSocketRpc = require("arc-rpc").ClientSocketRpc
let serverRpc = null
class ClientClass {
async clientTest() {
console.log("Remotely called by server, calling server method.")
await rpc.class.serverTest()
console.log("Called remote server method!")
}
}
serverRpc = new ClientSocketRpc ("127.0.0.1", 9919, Buffer.from ('flbd+mTz8bIWl2DQxFMKHYAA1+PFxpEKmVNsZpFP5xQ=', 'base64'), new ClientClass())
server.js
let ServerSocketRpcMaster = require("arc-rpc").ServerSocketRpcMaster
class ServerClass {
async serverTest() {
console.log("Remotely called by client.")
}
}
let rpcMaster = new ServerSocketRpcMaster (9919, Buffer.from ('flbd+mTz8bIWl2DQxFMKHYAA1+PFxpEKmVNsZpFP5xQ=', 'base64'), new ServerClass())
rpcMaster.on("client", async (clientRpc) => {
console.log("Got new client, remotely calling client test.")
await clientRpc.class.clientTest()
console.log("Remotely called client test!")
})
Basic documentation
I'll get to completing this later