PureMVC Architects Lounge

Announcements and General Discussion => Architecture => Topic started by: meatnugget on June 08, 2009, 01:43:28

Title: Basic Pipes question
Post by: meatnugget on June 08, 2009, 01:43:28

I'm just starting to work with pipes and I've run into a problem that is probably very basic, but the solution is eluding me...

I'm trying to do a simple framework where the shell has three modules and they can send messages back and forth. I used the PipeWorks and GarbageCollectionPipes demos as a base.

I create and connect the modules fine - they show up in the framework and I can send messages from the modules to the shell ( in the MODULE_TO_SHELL_PIPE ) However when i try to send messages the other way ( in the  SHELL_TO_MODULE_PIPE ) it fails. The chain stops when I try to send the mesage:

junction.sendMessage( PipeAwareModuleConstants.APP_TO_MODULE_PIPE, new Message( PipeAwareModuleConstants.APP_TO_MODULE_MESSAGE, null, note.getBody( ) ) );

I can see an Alert that happens before the call, but not after so I'm assuming it fails silently somewhere in the sending process.

I did one thing that might cause this ( can't really see where it would, but I'm a newbie ) - I wanted to be able to load MXML modules and not AS modules so I changed the "PipeAwareModule" to extend "Module" instead of "ModuleBase". Then I added a public "init" function that is overridden by modules extending "PipeAwareModule". I also added a "setFacade" since the MXML module does not have a constructor where it can pass that to super. This all happens before i try to connect the module to the Pipes so the facade is available when the ACCEPT_INPUT_PIPE and ACCEPT_OUTPUT_PIPE notifications are sent.

This might be the totally wrong way to approach this - and I'm very open to suggestions - but it seems to connect fine since I can send messages from the modules to the shell. (But not the other way around...)
Sorry for the lengthy explanation - if anyone has experienced anything similar, or see something inherently wrong with what I've tried to do I'd really appreciate any help I can get


Title: Re: Basic Pipes question
Post by: puremvc on June 08, 2009, 01:53:24
Difficult to tell from your post just what's happening, but I'm getting the sense from your post that you aren't using the debugger. Are you using FlexBuilder? If so, you really need to set a breakpoint on the call and step through, inspecting all the variables as you go.

Also, here are another couple of demos you can look at to get a handle on the pipes:




Title: Re: Basic Pipes question
Post by: meatnugget on June 08, 2009, 03:43:30
Hi Cliff - thanks for your quick reply - appreciate it!

You are correct - I was not using the Debugger - had the wrong version installed of the debugger player...
I installed the correct version and ran it with breakpoints when I send the message and it's telling me that the "shellOutFitting" is null. I'm not exactly sure why it is referencing that var by name since it is a local var in the function connecting the modules to the shell.

From what I gather the issue is with the write method on the pipe - the "output" in the pipe is returning null.

My head might not be quite around this yet, but when I look at how the pipes for modules are connected they never supply an output to the Pipe - either via constructor or via "connect" method.

var shellToModule:IPipeFitting = new Pipe( );
module.acceptInputPipe( PipeAwareModuleConstants.SHELL_TO_MODULE_PIPE, shellToModule );
var shellOutFitting:IPipeFitting = junction.retrievePipe( PipeAwareModuleConstants.SHELL_TO_MODULE_PIPE ) as IPipeFitting;
shellOutFitting.connect( shellToModule );

So am I looking at the wrong pipe? Should I be looking at the TeeSplit coming out from the Shell?


Title: Re: Basic Pipes question
Post by: meatnugget on June 08, 2009, 04:55:44
Wow - sometimes I really live up to my username...

The reason the MODULE_TO_SHELL_PIPE worked for one of the modules is that I noticed that I forgot to add the "default" case for the switch statement in the "handleNotification" method in the ModuleJunctionMediator. The very same that is supposed to handle ACCEPT_OUTPUT_PIPE and ACCEPT_INPUT_PIPE...

Unfortunately it took me until now ( about 5 hours ) to realize that I had missed adding it to the remaining two modules... hence output is returned null for two of the three pipes in the list.

Air in - frustration out. Yay brain!

Again thanks for listening to my ramblings - the debugger definitely helped me narrow the issue down.

Title: Re: Basic Pipes question
Post by: puremvc on June 09, 2009, 05:39:33
Glad to hear you ran it down. Gives you a new appreciation for your local plumber doesn't it?

Remember, crack kills :)