Search code examples
javascriptnoflo

Noflo: How to have a network with only one component


I am trying to integrate noflo in my browser application. To understand the send and receive of the IIP, I have created a 'forwarder component' which will just output whatever is input to it. I am creating a graph with just one component and trying to send IIP to it to extract a response.

My fbp code for testGraph is following:

# (all)
INPORT=Forwarder.IN:CONTENTIN
# (all)
OUTPORT=Forwarder.OUT:CONTENTOUT

following is my react call trying to send an IIP and extract a reply:

    const loader = new noflo.ComponentLoader(__dirname);
    loader.load('testGraph',(err,instance)=>{

        if(err){
            throw err;
        }
    instance.start((errr)=>{

        if(errr){
            throw errr;
        }
        const inp = noflo.internalSocket.createSocket();
        const outp = noflo.internalSocket.createSocket();

        instance.inPorts.CONTENTIN.attach(inp);
        instance.outPorts.CONTENTOUT.attach(outp);

        outp.on('ip',(ip)=>{
            console.log(ip);
        });

        inp.send('Test Start!');
    });

});

The problem is:

instance.inPorts.CONTENTIN.attach(inp);
instance.outPorts.CONTENTOUT.attach(outp);

because CONTENTIN and CONTENTOUT are undefined. I will appreciate greatly any help regarding this.

Thanks.


Solution

  • The graph has to be as below:

    # (all) 
    INPORT=Forward.IN:CONTENTIN
    # (all) 
    OUTPORT=Forward.OUT:CONTENTOUT 
    Forward(Forwarder)