Remote Procedure Calls (RPC)
spooky actions at a distance
Last updated
spooky actions at a distance
Last updated
© 2023 Atsign
RPC has been a design pattern for decades and no surprise we have RPC in the atSDK also. This demo code is in another directory named at_rpc_demo
. You can get to it by using VS Code and open folder and select that folder. Next once again open two windowpanes.
In the right hand pane enter (again using your atSigns!)
This pulls in needed libraries, and then this starts the RPC listener.
Then in the left window you can run up the client
You will get a prompt after a second or two and you can put in a math expression and hit enter. The expression will be send to the other atSign the answer calculated and then returned.
See our session in action:
Couple of things to notice here are that the RPC server will only respond to RPC's from the designated atSign with the --allow-list
argument.
The RPC can of course do anything you want it to and the atSigns can be running anywhere.
An AtRpc object is set up pretty simply with:
The Callbacks are sent to the DemoRpcServer
class and handled appropriately.
On the sending side the RPC client is initiated:
Then the RPC simple sent and awaiting a reply