REST or gRPC?
Both need a contract you maintain (routes, schemas, .proto files) and a server others can reach. VRPC needs neither: your class is the contract, and agents only connect out.
Call C++, Node.js, Python, and Arduino classes across any network as if they were local objects. Perfect for microservices, IoT edge devices, and directly driving React frontends without REST, GraphQL, or WebSocket boilerplate.
A browser asks a Raspberry Pi in the kitchen for the temperature, then listens to every new reading. In between: your MQTT broker, and no API layer.
const client = new VrpcClient({ domain: 'home' })
await client.connect()
const sensor = await client.getInstance('kitchen')
const celsius = await sensor.read() // 21.4
await sensor.onReading(c => chart.add(c))
class Sensor {
read () {
return this._adc.celsius()
}
onReading (handler) {
this._adc.on('reading', handler)
const off = () => this._adc.off('reading', handler)
return { [Symbol.dispose]: off }
}
}
VrpcAdapter.register(Sensor)
new VrpcAgent({ domain: 'home', agent: 'pi-kitchen' })
.serve()
home/pi-kitchen/Sensor/kitchen/read{"c":"kitchen","f":"read","a":[],"i":"Xa3kP9qz-1"}home/web-7f3a/k9x2{"r":21.4,"i":"Xa3kP9qz-1"}Both need a contract you maintain (routes, schemas, .proto files) and a server others can reach. VRPC needs neither: your class is the contract, and agents only connect out.
Then you write the RPC layer: matching answers to requests, timeouts, errors, discovery, knowing who still listens. VRPC is that layer, finished, tested and specified in 93 rules.
WAMP calls functions through its own router. VRPC calls objects: you create, call and delete them through the MQTT broker you already run, down to an ESP32.
Excellent transports. VRPC works a layer higher: objects with a lifecycle, and events that live as long as someone listens.
Building a public HTTP API for strangers? Use REST. VRPC is for programs that belong together.
Your classes are the interface: no schemas, routes or code generators.
on your devices: agents and clients only connect out, to the broker.
The MQTT broker you already run, such as Mosquitto or HiveMQ.
Node.js, React, Python, C++ and Arduino, speaking one protocol.
A written protocol, and tests that name the rules they check.
VRPC runs the Heisenware platform.
Start an agent on your machine, and this page finds it within a second - through your firewall, over a public broker - and can call it.
# 1. Prepare
npm init -y && npm install vrpc
# 2. Start the agent
node agent.js
const { VrpcAgent, VrpcAdapter } = require('vrpc')
class SystemInfo {
static greet(sender, message) {
console.log(`[INCOMING MESSAGE] from ${sender}: "${message}"`)
return 'Greetings from Node.js Edge Device! I got your message.'
}
}
VrpcAdapter.register(SystemInfo)
async function main() {
const agent = new VrpcAgent({
domain: 'vrpc-live-demo',
agent: `visitor-js-${Math.floor(Math.random() * 10000)}`,
broker: 'mqtts://broker.hivemq.com:8883'
})
await agent.serve()
console.log('Waiting for messages...\n')
}
main().catch(console.error)