The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Reflex::POE::Session - Observe events from a POE::Session object.

VERSION

version 0.060

SYNOPSIS

This sample usage is not a complete program. The rest of the program exists in eg-13-irc-bot.pl, in the tarball's eg directory.

        sub BUILD {
                my $self = shift;

                $self->component(
                        POE::Component::IRC->spawn(
                                nick    => "reflex_$$",
                                ircname => "Reflex Test Bot",
                                server  => "10.0.0.25",
                        ) || die "Drat: $!"
                );

                $self->poco_watcher(
                        Reflex::POE::Session->new(
                                sid => $self->component()->session_id(),
                        )
                );

                $self->run_within_session(
                        sub {
                                $self->component()->yield(register => "all");
                                $self->component()->yield(connect  => {});
                        }
                )
        }

DESCRIPTION

Reflex::POE::Session allows a Reflex::Base object to receive events from a specific POE::Session instance, identified by the session's ID.

Authors are encouraged to encapsulate POE sessions within Reflex objects. Most users should not need use Reflex::POE::Session (or other Reflex::POE helpers) directly.

Public Attributes

sid

The "sid" must contain the ID of the POE::Session to be watched. This is in fact how Reflex::POE::Session knows which session to watch. See POE for more information about session IDs.

Public Events

Reflex::POE::Session will emit() events on behalf of the watched POE::Session. If the session posts "irc_001", then Reflex::POE::Session will emit "irc_001", and so on.

Reflex::POE::Session's "args" parameter will contain all of the POE event's paramters, from ARG0 through the end of the parameter list. They will be mapped to Reflex paramters "0" through the last index.

Assume that this POE post() call invokes this Reflex callback() via Refex::POE::Session:

        $kernel->post( event => qw(one one two three five) );

        ...;

        sub callback {
                my ($self, $args) = @_;
                print(
                        "$args->{0}\n",
                        "$args->{1}\n",
                        "$args->{2}\n",
                        "$args->{3}\n",
                        "$args->{4}\n",
                );
        }

The callback will print five lines:

        one
        one
        two
        three
        five

CAVEATS

Reflex::POE::Session will take note of every event sent by the session, although it won't try to deliver ones that haven't been registered with the callback object. However, the act of filtering these events out is more overhead than simply not registering interest in the first place. A later version will be more optimal.

Reflex::POE::Wheel provides a way to map parameters to symbolic names. Reflex::POE::Session may also provide a similar mechanism in the future, obsoleting the parameter numbers.

SEE ALSO

Moose::Manual::Concepts

Reflex Reflex::POE::Event Reflex::POE::Postback Reflex::POE::Wheel::Run Reflex::POE::Wheel

"ACKNOWLEDGEMENTS" in Reflex "ASSISTANCE" in Reflex "AUTHORS" in Reflex "BUGS" in Reflex "BUGS" in Reflex "CONTRIBUTORS" in Reflex "COPYRIGHT" in Reflex "LICENSE" in Reflex "TODO" in Reflex