.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "POE::Component::PubSub 3pm" .TH POE::Component::PubSub 3pm "2022-06-17" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" POE::Component::PubSub \- A generic publish/subscribe POE::Component that enables POE::Sessions to publish events to which other POE::Sessions may subscribe. .SH "VERSION" .IX Header "VERSION" Version 0.04 .SH "SYNOPSIS" .IX Header "SYNOPSIS" # Instantiate the publish/subscriber with the alias \*(L"pub\*(R" POE::Component::PubSub\->new('pub'); .PP # Publish an event called \*(L"\s-1FOO\*(R". +PUBLISH_OUTPUT\s0 is actually optional. \&\f(CW$_\fR[\s-1KERNEL\s0]\->post('pub', 'publish', '\s-1FOO\s0', +PUBLISH_OUTPUT); .PP # Elsewhere, subscribe to that event, giving it an event to call # when the published event is fired. \&\f(CW$_\fR[\s-1KERNEL\s0]\->post('pub', 'subscribe', '\s-1FOO\s0', 'FireThisEvent'); .PP # Fire off the published event \&\f(CW$_\fR[\s-1KERNEL\s0]\->post('pub', '\s-1FOO\s0'); .PP # Publish an 'input' event \&\f(CW$_\fR[\s-1KERNEL\s0]\->post('pub', 'publish', '\s-1BAR\s0', +PUBLISH_INPUT, 'MyInputEvent'); .PP # Tear down the whole thing \&\f(CW$_\fR[\s-1KERNEL\s0]\->post('pub', 'destroy'); .SH "EVENTS" .IX Header "EVENTS" 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. .IP "'publish'" 4 .IX Item "'publish'" This is the event to use to publish events. It accepts one argument, the event to publish. The published event may not already be previously published. The event may be completely arbitrary and does not require the publisher to implement that event. Think of it as a name for a mailing list. .Sp 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. .Sp There are two types: \s-1PUBLISH_INPUT\s0 and \s-1PUBLISH_OUTPUT. PUBLISH_OUPUT\s0 is implied when no argument is supplied. .IP "'subscribe'" 4 .IX Item "'subscribe'" This is the event to use when subscribing to published events. It accepts two arguments: 1) the published event, and 2) the event name of the subscriber to be called when the published event is fired. The event doesn't need to be published prior to subscription to resolve chicken and egg problems in an async environment. But, the sender must own and implement the return event. .IP "'rescind'" 4 .IX Item "'rescind'" Use this event to stop publication of an event. It accepts one argument, the published event. The event must be published, and published by the sender of the rescind event. If the published event has any subscribers, a warning will be carp'd but execution will continue. .IP "'cancel'" 4 .IX Item "'cancel'" Cancel subscriptions to events with this event. It accepts one argment, the published event. The event must be published and the sender must be subscribed to the event. .IP "'_default'" 4 .IX Item "'_default'" After an event is published, the publisher may arbitrarily fire that event to this component and the subscribers will be notified by calling their respective return events with whatever arguments are passed by the publisher. The event must be published, owned by the publisher, and have subscribers for the event to be propagated. If any of the subscribers no longer has a valid return event their subscriptions will be cancelled and a warning will be carp'd. .IP "'listing'" 4 .IX Item "'listing'" To receive an array reference containing tuples of the event name, and the type of the events that are currently published within the component, call this event. It accepts one argument, the return event to fire with the listing. The sender must own the return event. .IP "'destroy'" 4 .IX Item "'destroy'" This event will simply destroy any of its current state and remove any and all aliases this session may have picked up. This should free up the session for garbage collection. .SH "CLASS METHODS" .IX Header "CLASS METHODS" .IP "POE::Component::PubSub\->new($alias)" 4 .IX Item "POE::Component::PubSub->new($alias)" This is the constructor for the publish subscribe component. It instantiates it's own session using the provided \f(CW$alias\fR argument to set its kernel alias. If no alias is provided, the default alias is '\s-1PUBLISH_SUBSCRIBE\s0'. .SH "DEBUGGING" .IX Header "DEBUGGING" .ie n .IP "$POE::Component::PubSub::TRACE_AND_DEBUG" 4 .el .IP "\f(CW$POE::Component::PubSub::TRACE_AND_DEBUG\fR" 4 .IX Item "$POE::Component::PubSub::TRACE_AND_DEBUG" To enable debugging within the component at the POE::Session level and also with various warnings, set this variable to logical true \s-1BEFORE\s0 calling \fBnew()\fR. .SH "NOTES" .IX Header "NOTES" 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. .PP 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 \s-1POE\s0 core, they may break this module. .SH "AUTHOR" .IX Header "AUTHOR" Nicholas R. Perez, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-poe\-component\-pubsub at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc POE::Component::PubSub .Ve .PP You can also look for information at: .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2008\-2009 Nicholas R. Perez, all rights reserved. .PP This program is released under the following license: gpl