Palmer // Inter Plugin communication

12 views
Skip to first unread message

Thomas Pujolle

unread,
Mar 2, 2011, 6:12:47 AM3/2/11
to pixlib
Hi all,

I'm working using the previous version of Palmer. As this last one is
similar to the one in pixlib 3, I hope the solution would be the same.

I need, in the simplest way to get two plugin to communicate with each
other, using firePublicEvent.

So far, I've got this:
var _lp:LearningApplication = new LearningApplication(this);
var _scormPlugin:ScormPlugin = new ScormPlugin();
_lp.addListener(_scormPlugin);

The two plugings, LearningApplication and ScormPlugin, extend
PluginListener,

The "addlistener" throw a warning in my logger: LearningApplication
doesn't have public dispatcher.

And I didn't find a way to get a public dispatcher, a proper one.

What am I missing here?

Mike

unread,
Mar 2, 2011, 8:35:26 AM3/2/11
to pixlib

As of PIXLIB 3, implementation for plugin communication used in non
IoC context has changed a little.


You must register dedicated channel for each plugin as follow in
constructors:

public function PluginA()
{
registerInternalChannel(this);
// only use for non IoC context
super();
}

public function PluginA()
{
registerInternalChannel(this);
// only use for non IoC context
super();
}


Then you add plugin listeners:

var pluginB : PXPlugin = new PluginB();
var pluginC : PXPlugin = new PluginC();

var pluginA : PluginA = new PluginA();
pluginA.addPluginListener(pluginB);
pluginA.addPluginEventListener("onShout", pluginB);
pluginA.talk();
pluginA.shout();
pluginA.kill(pluginB.channel);


Tutorials are on the way, meantime you can check PIXLIB 3 source code.
I'm pretty confident you'll understand those few changes ;)

Mike

unread,
Mar 2, 2011, 9:32:19 AM3/2/11
to pixlib
// plugins / channels definition
ChannelExpert.getInstance().registerChannel(new
EventChannel("PluginA_channelName"));
var pluginA : PluginA = new PluginA();
CoreFactory.getInstance().register("PluginA_channelName", pluginA);

ChannelExpert.getInstance().registerChannel(new
EventChannel("PluginB_channelName"));
var pluginB : PluginB = new PluginB();
CoreFactory.getInstance().register("PluginB_channelName", pluginB);

// public event
ApplicationBroadcaster.getInstance().addListener(pluginA,
pluginB.getChannel());

// external
ApplicationBroadcaster.getInstance().addEventListener("eventNameToListen",
pluginB, pluginA.getChannel());



By the way do not forget to initialize your plugins once instantiated
(initialization is handled automatically in ioc)

var pluginA : PluginA = new PluginA();
var pluginB : PXPlugin = new PluginB();
var pluginC : PXPlugin = new PluginC();

....

pluginA.onApplicationInit();
pluginB.onApplicationInit();
pluginC.onApplicationInit();

Thomas Pujolle

unread,
Mar 2, 2011, 10:01:55 AM3/2/11
to pixlib
Coooool thank you :)

I try this asap!

Thomas Pujolle

unread,
Mar 2, 2011, 9:23:35 AM3/2/11
to pixlib
I definitely get it here.

But in Palmer, in the old version I mean (http://code.google.com/p/
palmer/), I cannot get to find to way to make it work properly :(

Do you know the way?
Reply all
Reply to author
Forward
0 new messages