Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Pages: [1]
Print
Author Topic: Module to Module communication with Pipes?  (Read 11982 times)
mecheye
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« on: July 19, 2008, 12:54:48 »

I have a question about Module to Module communication to Pipes. I am liking PureMVC and Pipes very much, but have some questions about how to accomplish Module to Module communication with Pipes.

I want to have a system where modules can communicate with the shell, and also with other modules. I have some general ideas about how to do this, but I want to know what is generally accepted to be the best way:

  • On module load, go through the list of modules and have the Shell JunctionMediator go through the list of modules and add one or more input and output pipes for each module in the list against the module that was just initialized. This would require making a lot of pipes for simple messaging.
  • Create a "RedirectJunction" with a "sendMessageToModule" method that sends a special message type to the shell for redirection toward the correct module.

Also, why would use more than one pipe per module and more than one message type? I guess I'm a little confused as how something would differ from the standard setup.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #1 on: July 20, 2008, 05:04:35 »

The PipeWorks demo will show you modules talking to each other (Prattler->Log), modules talking to the Shell and the Shell talking to modules.

The plumbing in your app will be as unique as the plumbing in your house. What needs to be connected to what and how is entirely governed by your requirements.

There are plenty of ways to do things. Fo instance in PipeWorks, every Prattler module has a pipe to the Shell and a pipe to the Logger module. A way to economize the pipes there would be to have the modules send their log messages to the shell, and let the shell's JunctionMediator redirect those to the logger via its log pipe.

Sometimes you want the shell to have a 'broadcast pipe',(STDOUT TeeSplit) and connect it to every module, so that a message sent on that pipe will reach every module.

But, you still often want to be able to talk directly from the Shell to any given Module. So creating an output pipe in the shell, named after the module is a good way. To handle this.

The reason for having different message types is so that the properties can be strongly typed and there can be as many properties as you want. Working with modules is the ultimate degree of code separation, but if the modules must communicate without references to each other, then they must agree on a message format. You can send a generic message and cast it inside the receiving module but this is cumbersome if there are many properties to pass.

-=Cliff>   
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #2 on: July 20, 2008, 05:07:26 »

That is to say you can send a generic Message and cast its header and body properties, not the messag itself.

-=Cliff>
Logged
mecheye
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #3 on: July 20, 2008, 01:22:11 »

Okay. That helps, but if you take the PipeWorks demo, all the modules were compiled into the same application, and there were helper classes inside the common and shell packages (LogMessage, LoggingJunctionMediator). That's fine, but for places where modules are written by third parties and loaded dynamically, you can't have a "common" package to agree on a format, as third-parties would need to have access to modify the common package.

I believe that making a ModuleJunction with a "sendMessageToModule" that sends a special message to the shell on a special pipe to be redirected to the correct module (if it exists) is the best way to do this. I should note that since this is an RIA, these modules are not DisplayObject modules; they add features to the RIA, like plug-ins.

What other options are there? I can override the sendMessage method to look for a module with those wanted pipes, so I don't have to keep adding pipes here and there. But I could do it the hard way and create a sort-of polygonal figure with each diagonal being a pipe going from one module to another. The idea is that each module requests for input pipes to be added to every other module, so the LoggerModule requests a STDLOG as well as its usual input.

I would like some sort of "select valve" that works like a TeeSplit except you can toggle outputs on or off, so you can control which of the output pipes it goes to. Hmm... maybe I could make that.
« Last Edit: July 20, 2008, 01:30:45 by mecheye » Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #4 on: July 21, 2008, 05:07:58 »

Yes you can have classes that are shared between modules and the main app and still have third parties write modules. Simply put those classes into an API library (i.e. Move the pipeworks common package into a swc of its own and distribute that to your third parties. Then make sure its compiled into your main app.

And I like the 'select valve' idea.

-=Cliff>
Logged
mecheye
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #5 on: July 21, 2008, 04:35:53 »


Yeah, but what if a third-party wants a class from its module to be available for other modules to use? I think OSGi solves this, but I'm not sure. Also, I can try to create a select valve, I have a couple ideas.
Logged
puremvc
Global Moderator
Hero Member
*****
Posts: 2871



View Profile WWW Email
« Reply #6 on: July 21, 2008, 05:38:53 »

Maybe we should bat this idea around a little first.

The select valve should  be controlled like a filter or queue. That is you send it a ValveControlMessage, which tells it how to behave. 

Not only could you select a specific output, but you might select a group of outputs. A named group, perhaps.

So the idea is its like a splitting tee, and we can tell it, send this messag to a specific output (or group of outputs).

The outputs in a splitting tee are anonymous. Here they will need to be named. And we need a way to make them part of a group.

Ideas?

-=Cliff>   
Logged
mecheye
Courseware Beta
Newbie
***
Posts: 7


View Profile Email
« Reply #7 on: July 22, 2008, 11:34:04 »


Okay, I have made a first revision for a TaggedValve and Valve class.

There is no attachment on the forums here... so I will upload it on pastebin as a diff.

http://puremvc.pastebin.com/f3b7cf9be
Logged
Pages: [1]
Print