Mojo::FriendFeed - A non-blocking FriendFeed listener for Mojolicious
use Mojo::Base -strict;
use Mojo::IOLoop;
use Mojo::FriendFeed;
use Data::Dumper;
my $ff = Mojo::FriendFeed->new( request => '/feed/cpan' );
$ff->on( entry => sub { say Dumper $_[1] } );
$ff->listen;
Mojo::IOLoop->start;
A simple non-blocking FriendFeed listener for use with the Mojolicious toolkit. Its code is highly influenced by Miyagawa's AnyEvent::FriendFeed::Realtime.
Mojo::FriendFeed inherits all events from Mojo::EventEmitter and implements the following new ones.
$ff->on( entry => sub {
my ($ff, $entry) = @_;
...
});
Emitted when a new entry has been received, once for each entry. It is passed the instance and the data decoded from the JSON response.
$ff->on( error => sub {
my ($ff, $error, $status, $ff_error) = @_;
...
});
Emitted for transaction errors. Fatal if not handled. It is passed the instance, the HTTP error message, HTTP status, and the "errorCode" sent from FriendFeed if available. Note that after emitting the error event, the listen
method exits, though you may use this hook to re-attach if desired.
$ff->on( error => sub { shift->listen } );
Mojo::FriendFeed inherits all attributes from Mojo::EventEmitter and implements the following new ones.
The feed to request. Default is an empty string.
An instance of Mojo::UserAgent for making the feed request.
The (generated) url of the feed. Using the default value is recommended.
Your FriendFeed username. If set, authentication will be used.
Your FriendFeed API key. Unused unless username
is set.
Mojo::FriendFeed inherits all methods from Mojo::EventEmitter and implements the following new ones.
Connects to the feed and attaches events. Note that this does not start an IOLoop and will not block.
Mojolicious - High performance non-blocking web framework and toolkit for Perl
Mojo::IRC - IRC interaction for use with the Mojolicious' Mojo::IOLoop
AnyEvent::FriendFeed::Realtime - The inspiration for this module, useful when using AnyEvent
http://github.com/jberger/Mojo-FriendFeed
Joel Berger, <joel.a.berger@gmail.com>
Copyright (C) 2014 by Joel Berger
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.