tag:robotlegs.tenderapp.com,2009-10-18:/discussions/robotlegs-2/12067-different-channeldispatchersRobotlegs: Discussion 2018-10-18T16:35:56Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/345472732014-09-12T09:02:12Z2014-09-12T09:03:26ZDifferent ChannelDispatchers<div><p>Well, come to think of it, I guess you could have two different
contexts who are interested in the same event but from different
channels.</p></div>Philiptag:robotlegs.tenderapp.com,2009-10-18:Comment/345472732014-09-12T10:35:32Z2014-09-12T10:35:32ZDifferent ChannelDispatchers<div><p>Hey Philip,</p>
<p>Yes, it might be a bit confusing, firstly, because there are 2
kinds of channels: the default channel, and custom channels, and
secondly because there are 2 slightly different examples:</p>
<p>a.<br>
<a href=
"https://github.com/Ondina/robotlegs-bender-modular-air">https://github.com/Ondina/robotlegs-bender-modular-air</a>
(see the readme)<br>
Here, I wanted to show how that works for both situations, default
and custom channels</p>
<p>and</p>
<p>b.<br>
<a href=
"https://github.com/Ondina/robotlegs-bender-as3-modular-example">https://github.com/Ondina/robotlegs-bender-as3-modular-example</a><br>
Here, it was about having multiple custom channels, and also models
and commands</p>
<p>Maybe I should make it more clear in the readme files that there
are 2 kinds of channels, when I get a chance...</p>
<p>When you use moduleConnector.onDefaultChannel(), the modularity
extension is defining a channel internally, and all you have to do
is find good names for your events:</p>
<p>SHELL</p>
<pre>
<code>moduleConnector.onDefaultChannel()
.relayEvent(ModularConnectorEvent.SHELL_TO_MODULES_MESSAGE);
moduleConnector.onDefaultChannel()
.receiveEvent(ModularConnectorEvent.MODULES_TO_SHELL_MESSAGE);</code>
</pre>
<p>MODULE</p>
<pre>
<code>moduleConnector.onDefaultChannel()
.receiveEvent(ModularConnectorEvent.SHELL_TO_MODULES_MESSAGE);
moduleConnector.onDefaultChannel()
.relayEvent(ModularConnectorEvent.MODULES_TO_SHELL_MESSAGE);</code>
</pre>
<p>Obviously, with
moduleConnector.onChannel('name_of_your_custom_channel') we can
name the channels as we wish.</p>
<p>So, you can use one single channel (default or custom), but you
have to use different event types for the relaying and receiving
events. There is still an unsolved issue with the moduleConnector
when using the same event type for relying and receiving events -
causing an infinite loop, but that's probably not affecting
you.</p>
<p>Having multiple custom channels is a matter of preferences.
Those were silly names in my examples, but in a real project, you
might want to name your channels and the event types in a way that
makes sense to you. The names should help you see the relationship
between the modules and their roles.</p>
<p>Let me know, whether the above explanation made things more
clear, or on the contrary it made the confusion even worse;)</p>
<p>Ondina</p></div>Ondina D.F.tag:robotlegs.tenderapp.com,2009-10-18:Comment/345472732014-09-12T11:14:58Z2014-09-12T11:14:58ZDifferent ChannelDispatchers<div><p>Your explanation is clear. I think I will use custom channel
names as indexical tokens then. Could be quite helpful.</p>
<p>Thanks again,<br>
Philip</p></div>Philip