NAME
WWW::PubNub - PubNub API
VERSION
version 0.001
SYNOPSIS
use WWW::PubNub;
my $pubnub = WWW::PubNub->new(
subscribe_key => 'demo',
publish_key => 'demo', # not supported yet
);
#
# Blocking usage
#
#################
$pubnub->subscribe(
my_channel => sub { # $_[0] is a WWW::PubNub::Message
print "It is said ".$_[0]->get('text')."\n"; # helper function for accessing raw message
},
);
# alternative shortcut:
WWW::PubNub->subscribe( demo => my_channel => sub { ... } );
# multi subscription works out of box:
$pubnub->subscribe(
[qw( my_channel1 my_channel2 )] => sub { # called on any message (optional)
print "On ".$_[0]->channel." it is said ".$_[0]->message->{text}."\n";
},
my_channel2 => sub { ... }, # only called for specific channel
);
# multi subscription and raw
$pubnub->subscribe(
[qw( my_channel1 my_channel2 )] => sub {
my ( $message, $channel ) = @_;
print "On ".$channel." it is said ".$message->{text}."\n"; # raw message of PubNub
},
raw => 1,
);
#
# Non-Blocking usage
#
#####################
my $request = $pubnub->subscribe_request('my_channel');
# Repeat:
my $response = your_http_agent($request);
my ( $next_request, @messages ) = $pubnub->subscribe_next_request_and_messages($response);
# There can be no messages! Do something with the messages, repeat with $next_request
DESCRIPTION
Module for using the PubNub API.
A message is a WWW::PubNub::Message object.
Publish not yet implemented
More documentation to come...
More tests to come...
INIT ARGS
subscribe_key
Subscribe key used for PubNub.
publish_key
Publish key used for PubNub. (Not supported yet)
METHODS
subscribe
Takes a channel name or an arrayref of channel names as argument, followed by a coderef which gets called for every new message. After that a hash of arguments can be used to add additional coderefs for specific events:
SPONSORING
This distribution is sponsored by RealEstateCE.com.
SUPPORT
IRC
/msg Getty on irc.perl.org or chat.freenode.net.
Repository
https://github.com/Getty/p5-www-pubnub
Pull request and additional contributors are welcome
Issue Tracker
https://github.com/Getty/p5-www-pubnub/issues
AUTHOR
Torsten Raudssus <torsten@raudss.us>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.