PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: emurphy on June 04, 2010, 08:33:48



Title: disconnecting pipes
Post by: emurphy on June 04, 2010, 08:33:48
So I read the whole thread on disconnecting pipes but still didn't find what I was looking for. Here is what I am currently doing:

:
//remove the pipe
var shellJunction:Junction = QueryMessage(message).getBody() as Junction;

//disconnect the input pipe
var pipeIn:Pipe = junction.retrievePipe(PipeAwareModule.SHELL_IN) as Pipe;
var shellOut:TeeSplit = shellJunction.retrievePipe(PipeAwareModule.STD_OUT) as TeeSplit;
shellOut.disconnectFitting(pipeIn);

So this disconnects the pipe coming out of the shell into the module. I wanted to also disconnect the pipe for traffic out of the module to the shell but the TeeMerge on the shell doesn't have a "disconnectFitting" method. It only has a "disconnect" method. How do I go about disconnecting the module input pipe from the shell without disconnecting all other input pipes to the shell?


Title: Re: disconnecting pipes
Post by: puremvc on June 04, 2010, 05:06:02
I wanted to also disconnect the pipe for traffic out of the module to the shell but the TeeMerge on the shell doesn't have a "disconnectFitting" method.
Just remove the output pipe from the module's Junction (from within the module obviously). This means that before you disconnect the pipe going from the shell to the module, you need to send a message to the module telling it to disconnect its output to the shell first. Then disconnect the shell output to that module and your module is completely disconnected.

This leaves the loose pipe connected to the shell's TeeMerge, but that's no big deal; nothing's going to be sent to it and since it's an input pipe (from the shell's perspective) there's no danger of write errors. The module will no longer have a reference to it and so it can be GC'd (assuming all other references have been cleaned up).

-=Cliff>


Title: Re: disconnecting pipes
Post by: emurphy on June 07, 2010, 11:34:08
Thanks, that makes sense. I just didn't know if it was OK to leave that pipe hanging there.
-erik