chr15m / bugout

Back end web app services over WebRTC.
https://chr15m.github.io/bugout
MIT License
607 stars 59 forks source link

Public rpc? #9

Closed davay42 closed 5 years ago

davay42 commented 5 years ago

I test the code from docs in my app and can't figure out how to call a public RPC without the address as the first argument. With b.rpc("ping", {"Hello": "world"}, console.log("response:")); i get ping not seen - no public key.

As i understand RPC can be better to use to send many small packets (like mouseposition or midi) than the b.send() method, isn't it? Is it optimized some how better than if I send {type:'type',{data:'data'}} messages with b.send()?

chr15m commented 5 years ago

RPC is useful for calling a function on some node and then receiving the result of that function. That's why the address of the node is required (I need to update the error message to say "address" not public key).

When sending mouse / MIDI I guess you aren't looking for a reply from the other side. In this case you should use send yes. RPC is actually less efficient than send as it has to do a bunch of work to track responses.