Skip to content
Nick O'Leary edited this page Sep 7, 2013 · 20 revisions

Server

Nodes

  • RED.nodes.addCredentials(id,credentials)
  • RED.nodes.getCredentials(id)
  • RED.nodes.deleteCredentials(id)

[HTTP Server](API/Server/HTTP Server)

  • RED.server.app - the Express instance serving the editor UI
  • RED.server.server - the server instance

Client

  • RED.nodes.registerType(type,node)
  • RED.library.create({})
  • RED.nodes.eachNode(cb)
  • RED.nodes.eachLink(cb)
  • RED.nodes.eachConfig(cb)
  • RED.nodes.node(id)
  • RED.validators.number()
  • RED.validators.regex(re)
  • RED.view.redraw
  • RED.view.dirty(dirty)
  • RED.sidebar.addTab(title,content)
  • RED.notify(msg,type)

# RED.nodes.Node

All nodes extend this class. It handles the wiring between nodes and other things. It should not be instantiated directly, rather RED.nodes.createNode should be called from the constructor of the sub-class.

The class defines the following functions/events:

# node.send(msg)

This function causes the message(s) to be sent on to any nodes wired to this one. A node can have multiple outputs and each output can be wired to multiple nodes.

  • If msg is a single message, it is sent on to any nodes wired to the first output.
  • If msg is an array, each element of the array is passed to the corresponding output.
  • If any of these elements is itself an array, each element of that array is sent to the connected nodes in order.

# 'input' event

This event is emitted when the node receives an inbound message. The node should register a listener for this event in order to handle the message.

this.on("input",function(msg) {
    var msg = {topic:this.topic,payload:this.payload};
    if (msg.payload == "") { msg.payload = Date.now(); }
    this.send(msg);
});

# node.close()

This function is called when the node is being stopped, for example when a new flow configuration is deployed. This allows the node to release any resources, such as network connections, it has open.

For example, the Inject node clears the timer if one had been set:

InjectNode.prototype.close = function() {
    if (this.interval_id != null) {
        clearInterval(this.interval_id);
    }
}

# node.log(msg)

# node.warn(msg)

# node.error(msg)

Three log level functions are provided for convenience. They format the log message with the time-stamp and ID of the node. If the Debug node is active, the log messages will appear in the debug sidebar.

# RED.nodes.createNode(node,definition)

# RED.nodes.registerType(type,node)

# RED.library.register(type)

Clone this wiki locally