coap/coap-in.js
function CoapServerNode(n) {
        // Create a RED node
        RED.nodes.createNode(this,n);
        var node = this;

        // Store local copies of the node configuration (as defined in the .html)
        node.options = {};
        node.options.name = n.name;
        node.options.port = n.port;

        node._inputNodes = [];    // collection of "coap in" nodes that represent coap resources

        // Setup node-coap server and start
        node.server = new coap.createServer();
        node.server.on('request', function(req, res) {
            node.handleRequest(req, res);
            res.on('error', function(err) {
                node.log('server error');
                node.log(err);
            });
        });
        node.server.listen(node.options.port, function() {
            //console.log('server started');
            node.log('CoAP Server Started');
        });

        node.on("close", function() {
            node._inputNodes = [];
            node.server.close();
        });
    }
function CoapServerNode(n) {
        // Create a RED node
        RED.nodes.createNode(this,n);
        var node = this;

        // Store local copies of the node configuration (as defined in the .html)
        node.options = {};
        node.options.name = n.name;
        node.options.port = n.port;

        node._inputNodes = [];    // collection of "coap in" nodes that represent coap resources

        // Setup node-coap server and start
        node.server = new coap.createServer();
        node.server.on('request', function(req, res) {
            node.handleRequest(req, res);
            res.on('error', function(err) {
                node.log('server error');
                node.log(err);
            });
        });
        node.server.listen(node.options.port, function() {
            //console.log('server started');
            node.log('CoAP Server Started');
        });

        node.on("close", function() {
            node._inputNodes = [];
            node.server.close();
        });
    }
function CoapServerNode ( n ) { // Create a RED node RED . nodes . createNode ( this , n ) ; var node = this ; // Store local copies of the node configuration (as defined in the .html) node . options = { } ; node . options . name = n . name ; node . options . port = n . port ; node . _inputNodes = [ ] ; // collection of "coap in" nodes that represent coap resources // Setup node-coap server and start node . server = new coap . createServer ( ) ; node . server . on ( 'request' , function ( req , res ) { node . handleRequest ( req , res ) ; res . on ( 'error' , function ( err ) { node . log ( 'server error' ) ; node . log ( err ) ; } ) ; } ) ; node . server . listen ( node . options . port , function ( ) { //console.log('server started'); node . log ( 'CoAP Server Started' ) ; } ) ; node . on ( "close" , function ( ) { node . _inputNodes = [ ] ; node . server . close ( ) ; } ) ; }
A node red node that sets up a local coap server
A node red node that sets up a local coap server