An example echo funnel, with a simulator.
A MessageResponse encapsulates a message.
NoResponse is currently unused, but many PortFunnel-aware modules will need it.
CmdResponse denotes a message that needs to be sent through the port. This is done by the commander function.
ListResponse allows us to return multiple responses. commander descends a ListResponse looking for CmdResponse responses. findMessages descends a list of Response records, collecting the MessageResponse messages.
Our internal state.
Just tracks all incoming messages.
PortFunnel.FunnelSpecThe name of this module: "Echo".
Our module descriptor.
Responsible for sending a CmdResponse back througt the port.
Called by PortFunnel.appProcess for each response returned by process.
StateThe initial, empty state, so the application can initialize its state.
Message out the Cmd PortMake a message to send out through the port.
Convert a Message to the same JSON string that gets sent
over the wire to the JS code.
Make a simulated Cmd port.
Returns true if a Startup message has been processed.
This is sent by the port code after it has initialized.
When it needs to send the tail of a message beginning with a dollar sign
through the port, the Echo module returns a ListResponse. This function recursively descends a ListResponse, and returns a list of the Messages from any MessageResponses it finds.
Convert our State to a list of strings.
Since this is a simple echo example, the messages are just strings.