NAME

XAS::Lib::POE::PubSub - A publish/subscribe class for POE sessions

SYNOPSIS

use POE;
use XAS::Lib::POE::PubSub;

my $pubsub = XAS::Lib::POE::PubSub->new();

$pubsub->subscribe('session', 'channel');
$pubusb->publish(
   -event   => 'event',
   -channel => 'channel', 
);

DESCRIPTION

This is a very simple channel based publish/subscribe framework for POE. It is implemented as a singleton. It allows you to publish events to all interested sessions.

METHODS

subscribe($session, $channel);

This method allows you to subscribe to the specified channel.

$session

The session name.

$channel

The optional channel to subscribe too. Defaults to 'default'.

unsubscribe($session, $channel);

This method allows you to unsubscribe from the specified channel.

$session

The session name.

$channel

The optional channel to unsubscribe from. Defaults to 'default'.

publish

This method allows you to publish an event to a specified channel. Additional arguuments can be supplied. It takes the following parameters:

-event

The event to send.

-channel

Optional channel. Defaults to 'default'.

-args

Optional additional arguments to send with the event. The context of the arguments is determined by the method that is handling the event. For example:

-args => ['this', 'is', 'neat']
-args => { this => 'is neat' }
-args => 'this is neat'

Are all valid arguments.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.