rhea/rhea.js
function amqpEndpointNode(n) {

        RED.nodes.createNode(this, n);

        // save node parameters
        this.host = n.host;
        this.port = n.port;
        this.username = n.username;
        this.password = n.password;
        this.container_id = n.container_id;
        this.rejectUnauthorized = n.rejectUnauthorized;
        this.usetls = n.usetls;

        if (this.usetls && n.tls) {
            this.tls = RED.nodes.getNode(n.tls)
        }

        // build options for connection
        var options = { host: this.host, port: this.port};
        if (this.username) {
            options.username = this.username;
        }
        if (this.password) {
            options.password = this.password;
        }
        if (this.container_id) {
            options.container_id = this.container_id;
        } else {
            options.container_id = "node-red-rhea-" + container.generate_uuid();
        }
        if (this.usetls && n.tls) {
            options.transport = 'tls';
            if (this.tls.credentials.cadata) {
                options.ca = this.tls.credentials.cadata
            }
        }

        options.rejectUnauthorized = this.rejectUnauthorized;

        var node = this;

        this.connected = false;
        this.connecting = false;
        
        /**
         * Exposed function for connecting to the remote AMQP container
         * creating an AMQP connection object
         *
         * @param callback  function called when the connection is established
         */
        this.connect = function(callback) {

            // AMQP connection not established, trying to do that
            if (!node.connected && !node.connecting) {

                node.connecting = true;

                node.connection = container.connect(options);

                node.connection.on('connection_error', function(context) {

                    node.connecting = false;
                    node.connected = false;
                    var error = context.connection.get_error();
                    node.error(error);

                });

                node.connection.on('connection_open', function(context) {

                    node.connecting = false;
                    node.connected = true;

                    callback(context.connection);
                });

                node.connection.on('disconnected', function(context) {

                    node.connected = false;
                });

            // AMQP connection already established
            } else {

                callback(node.connection);
            }

        }
    }
function amqpEndpointNode(n) {

        RED.nodes.createNode(this, n);

        // save node parameters
        this.host = n.host;
        this.port = n.port;
        this.username = n.username;
        this.password = n.password;
        this.container_id = n.container_id;
        this.rejectUnauthorized = n.rejectUnauthorized;
        this.usetls = n.usetls;

        if (this.usetls && n.tls) {
            this.tls = RED.nodes.getNode(n.tls)
        }

        // build options for connection
        var options = { host: this.host, port: this.port};
        if (this.username) {
            options.username = this.username;
        }
        if (this.password) {
            options.password = this.password;
        }
        if (this.container_id) {
            options.container_id = this.container_id;
        } else {
            options.container_id = "node-red-rhea-" + container.generate_uuid();
        }
        if (this.usetls && n.tls) {
            options.transport = 'tls';
            if (this.tls.credentials.cadata) {
                options.ca = this.tls.credentials.cadata
            }
        }

        options.rejectUnauthorized = this.rejectUnauthorized;

        var node = this;

        this.connected = false;
        this.connecting = false;
        
        /**
         * Exposed function for connecting to the remote AMQP container
         * creating an AMQP connection object
         *
         * @param callback  function called when the connection is established
         */
        this.connect = function(callback) {

            // AMQP connection not established, trying to do that
            if (!node.connected && !node.connecting) {

                node.connecting = true;

                node.connection = container.connect(options);

                node.connection.on('connection_error', function(context) {

                    node.connecting = false;
                    node.connected = false;
                    var error = context.connection.get_error();
                    node.error(error);

                });

                node.connection.on('connection_open', function(context) {

                    node.connecting = false;
                    node.connected = true;

                    callback(context.connection);
                });

                node.connection.on('disconnected', function(context) {

                    node.connected = false;
                });

            // AMQP connection already established
            } else {

                callback(node.connection);
            }

        }
    }
function amqpEndpointNode ( n ) { RED . nodes . createNode ( this , n ) ; // save node parameters this . host = n . host ; this . port = n . port ; this . username = n . username ; this . password = n . password ; this . container_id = n . container_id ; this . rejectUnauthorized = n . rejectUnauthorized ; this . usetls = n . usetls ; if ( this . usetls && n . tls ) { this . tls = RED . nodes . getNode ( n . tls ) } // build options for connection var options = { host : this . host , port : this . port } ; if ( this . username ) { options . username = this . username ; } if ( this . password ) { options . password = this . password ; } if ( this . container_id ) { options . container_id = this . container_id ; } else { options . container_id = "node-red-rhea-" + container . generate_uuid ( ) ; } if ( this . usetls && n . tls ) { options . transport = 'tls' ; if ( this . tls . credentials . cadata ) { options . ca = this . tls . credentials . cadata } } options . rejectUnauthorized = this . rejectUnauthorized ; var node = this ; this . connected = false ; this . connecting = false ; /**
         * Exposed function for connecting to the remote AMQP container
         * creating an AMQP connection object
         *
         * @param callback  function called when the connection is established
         */ this . connect = function ( callback ) { // AMQP connection not established, trying to do that if ( ! node . connected && ! node . connecting ) { node . connecting = true ; node . connection = container . connect ( options ) ; node . connection . on ( 'connection_error' , function ( context ) { node . connecting = false ; node . connected = false ; var error = context . connection . get_error ( ) ; node . error ( error ) ; } ) ; node . connection . on ( 'connection_open' , function ( context ) { node . connecting = false ; node . connected = true ; callback ( context . connection ) ; } ) ; node . connection . on ( 'disconnected' , function ( context ) { node . connected = false ; } ) ; // AMQP connection already established } else { callback ( node . connection ) ; } } }
Node for configuring an AMQP endpoint
Node for configuring an AMQP endpoint