Skip to content

2. Flowchain Node APIs

jollen chen edited this page Mar 30, 2018 · 1 revision

APIs

Class: BootNode

To start a boot node server:

var BootNode = require('./index').BootNode;
var node = new BootNode();

node.start();

BootNode.start(options)

  • options <Object> Options containing response events.
    • onstart <function> Callback function that notifies the success of creating the Websocket connection.
    • onmessage <Function> Callback function that receives client data
    • onquery <Function> Callback function that receives client data
    • ondata <Function> Callback function that receives client data

Example:

// Start the boot node with event handlers
node.start({
	onstart: onstart,
	onmessage: onmessage,
	onquery: onquery,
	ondata: ondata
});

<Function> onstart(req, res)

Example:

var onstart = function(req, res) {
    // Chord node ID
    var id = req.node.id;

    // Node IP address
    var address = req.node.address;
};

<Function> onmessage(req, res)

<Function> onquery(req, res)

<Function> ondata(req, res)