Skip to content

Remote Process Communication

simen edited this page May 12, 2017 · 4 revisions

The freebird is a framework to manage a machine network composed of various protocols, such as BLE, ZigBee, MQTT, and CoAP, with a single unified interface. This makes things easier for developers to build an IoT web apps or mobile apps.


Create a Channel for Remote Process Communication (RPC)

To communicate with freebird, a client/server model can be applied. Here, the freebird is a server and your apps are the clients.

There are many ways to implement RPC channels, for example, use TCP sockets, RESTful APIs, WebSockets, etc. The freebird has a ready-made RPC module freebird-rpc based on WebSocket for your convenience.

If you like to create your own RPC channel to be used in the freebird framework, please see the documentation of freebird-transport for more details.


How to add a transport for RPC

Assume that you have got your transport instance ready, just call freebird.addTransport() to register it to freebird for RPC messaging:

  • Server-side
var fooRpcTrasnport = require('./fooRpcTrasnport');
var myRpcServer;

/* initialize a server-side transport instance to myRpcServer */

// ...

// register to the freebird

freebird.addTransport(myRpcServer, function (err) {
    if (err)
        console.log(err);
});
  • Client-side
    • Depends on your implementation.