POE::Component::PubSub(3pm) | User Contributed Perl Documentation | POE::Component::PubSub(3pm) |
POE::Component::PubSub - A generic publish/subscribe POE::Component that enables POE::Sessions to publish events to which other POE::Sessions may subscribe.
Version 0.04
# Instantiate the publish/subscriber with the alias "pub" POE::Component::PubSub->new('pub');
# Publish an event called "FOO". +PUBLISH_OUTPUT is actually optional. $_[KERNEL]->post('pub', 'publish', 'FOO', +PUBLISH_OUTPUT);
# Elsewhere, subscribe to that event, giving it an event to call # when the published event is fired. $_[KERNEL]->post('pub', 'subscribe', 'FOO', 'FireThisEvent');
# Fire off the published event $_[KERNEL]->post('pub', 'FOO');
# Publish an 'input' event $_[KERNEL]->post('pub', 'publish', 'BAR', +PUBLISH_INPUT, 'MyInputEvent');
# Tear down the whole thing $_[KERNEL]->post('pub', 'destroy');
All public events do some sanity checking to make sure of a couple of things before allowing the events such as checking to make sure the posting session actually owns the event it is publishing, or that the event passed as the return event during subscription is owned by the sender. When one of those cases comes up, an error is carp'd, and the event returns without stopping execution.
You can also publish an 'input' or inverse event. This allows for arbitrary sessions to post to your event. In this case, you must supply the optional published event type and the event to be called when the published event fires.
There are two types: PUBLISH_INPUT and PUBLISH_OUTPUT. PUBLISH_OUPUT is implied when no argument is supplied.
Right now this component is extremely simple, but thorough when it comes to checking the various requirements for publishing and subscribing. Currently, there is no mechanism to place meta-subscriptions to the events of the component itself. This feature is planned for the next release.
Also, to do some of the checking on whether subscribers own the return events, some ideas were lifted from POE::API::Peek, and like that module, if there are changes to the POE core, they may break this module.
Nicholas R. Perez, "<nperez at cpan.org>"
Please report any bugs or feature requests to "bug-poe-component-pubsub at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Component-PubSub>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc POE::Component::PubSub
You can also look for information at:
<http://annocpan.org/dist/POE-Component-PubSub>
<http://cpanratings.perl.org/d/POE-Component-PubSub>
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-PubSub>
<http://search.cpan.org/dist/POE-Component-PubSub>
Copyright 2008-2009 Nicholas R. Perez, all rights reserved.
This program is released under the following license: gpl
2022-06-17 | perl v5.34.0 |