NAME
POE::Component::Net::LastFM::Submission - non-blocking wrapper around Net::LastFM::Submission
SYNOPSIS
use strict;
use POE qw(Component::Net::LastFM::Submission);
POE::Component::Net::LastFM::Submission->spawn(
Alias => 'LASTFM_SUBMIT',
LastFM => {
user => 'net_lastfm',
password => '12',
},
);
POE::Session->create(
options => { trace => 1 },
inline_states => {
_start => sub {
$_[KERNEL]->post('LASTFM_SUBMIT' => 'handshake' => 'np');
$_[KERNEL]->yield('_delay');
},
_delay => sub { $_[KERNEL]->delay($_[STATE] => 5) },
np => sub {
$_[KERNEL]->post(
'LASTFM_SUBMIT' => 'now_playing' => 'np',
{'artist' => 'ArtistName', 'title' => 'TrackTitle'}
);
},
}
);
POE::Kernel->run;
DESCRIPTION
The module is a non-blocking wrapper around Net::LastFM::Submission module, it is truelly asynchronously. Net::LastFM::Submission contains methods for generate requests and parse response (version >= 0.5). See documentation Net::LastFM::Submission.
POE::Component::Net::LastFM::Submission uses POE::Component::Client::HTTP. It lets other sessions run while HTTP transactions are being processed, and it lets several HTTP transactions be processed in parallel.
METHODS
spawn
POE::Component::Net::LastFM::Submission->spawn(
Alias => 'LASTFM_SUBMIT',
LastFM => {
user => 'net_lastfm',
password => '12',
},
);
PoCo::Net::LastFM::Submission's spawn method takes a few named parameters:
Alias
Alias sets the name by which the session will be known. If no alias is given, the component defaults is LASTFM_SUBMISSION. The alias lets several sessions interact with HTTP components without keeping (or even knowing) hard references to them. It's possible to spawn several Submission components with different names.
This is a constructor for Net::LastFM::Submission object. It takes list of parameters or hashref parameter.
LastFM
The data for Net::LastFM::Submission constructor. It's hashref of data. Required. See Net::LastFM::Submission.
Agent
The user agent of the client. Optional. It is a agent of PoCo::Client::HTTP. See POE::Component::Client::HTTP.
Timeout
The timeout of the client. Optional. It is a timeout of PoCo::Client::HTTP. See POE::Component::Client::HTTP.
ACCEPTED EVENTS
Sessions communicate asynchronously with PoCo::Net::LastFM::Submission. They post requests to it, and it posts responses back.
Events have syntax like PoCo::Client::HTTP.
First param is a alias of submission session.
Second param is accepted event such as handshake, now_playing and submit.
Third param is a event for return after execute request.
Forth param and so on are params for the accepted event (for real method of Net::LastFM::Submission).
handshake
$_[KERNEL]->post('LASTFM_SUBMIT' => 'handshake' => 'np');
now_playing
$_[KERNEL]->post(
'LASTFM_SUBMIT' => 'now_playing' => 'np',
{'artist' => 'ArtistName', 'title' => 'TrackTitle'} # params of now_playing
);
See params of now_playing in Net::LastFM::Submission.
submit
$_[KERNEL]->post(
'LASTFM_SUBMIT' => 'submit' => 'sb',
{'artist' => 'ArtistName', 'title' => 'TrackTitle', 'time' => time - 10*60} # params of submit
);
See params of submit in Net::LastFM::Submission.
TRACE MODE
The module supports trace mode - trace POE session.
BEGIN { $ENV{SUBMISSION_TRACE}++ };
use POE::Component::Net::LastFM::Submission;
EXAMPLES
See examples/poe.pl in this distributive.
SEE ALSO
DEPENDENCIES
Net::LastFM::Submission POE::Component::Client::HTTP POE::Session Carp
AUTHOR
Anatoly Sharifulin, <sharifulin at gmail.com>
BUGS
Please report any bugs or feature requests to bug-net-lastfm-submission at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-LastFM-Submission. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT & DOCUMENTATION
You can find documentation for this module with the perldoc command.
perldoc Net::LastFM::Submission
perldoc POE::Component::Net::LastFM::Submission
You can also look for information at:
Github
http://github.com/sharifulin/net-lastfm-submission/tree/master
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-LastFM-Submission
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
COPYRIGHT & LICENSE
Copyright (C) 2009 Anatoly Sharifulin
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.