POE::Component::Net::LastFM::Submission - non-blocking wrapper around Net::LastFM::Submission
use strict; use POE qw(Component::Net::LastFM::Submission); use Data::Dumper; 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 { warn Dumper @_[ARG0..$#_]; $_[KERNEL]->post( 'LASTFM_SUBMIT' => 'now_playing' => 'np', {'artist' => 'ArtistName', 'title' => 'TrackTitle'}, 'job_id' ); }, } ); POE::Kernel->run;
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 start own POE::Component::Client::HTTP when the user didn't supply the parameter Client. It lets other sessions run while HTTP transactions are being processed, and it lets several HTTP transactions be processed in parallel.
POE::Component::Net::LastFM::Submission->spawn( Alias => 'LASTFM_SUBMIT', LastFM => { user => 'net_lastfm', password => '12', }, ); # or POE::Component::Client::HTTP->spawn( Alias => 'HTTP_CLIENT', ... ); POE::Component::Net::LastFM::Submission->spawn( Alias => 'LASTFM_SUBMIT', Client => 'HTTP_CLIENT', # alias or session id of PoCo::Client::HTTP 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.
Client
The alias or session id of an existing PoCo::Client::HTTP. Optional. See POE::Component::Client::HTTP.
Agent
The user agent of the client. Optional. It is a agent of own PoCo::Client::HTTP. See POE::Component::Client::HTTP.
Timeout
The timeout of the client. Optional. It is a timeout of own PoCo::Client::HTTP. See POE::Component::Client::HTTP.
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 is hashref param for the accepted event (for real method of Net::LastFM::Submission).
Fiveth param is a tag to identify the request.
$_[KERNEL]->post('LASTFM_SUBMIT' => 'handshake' => 'np');
$_[KERNEL]->post( 'LASTFM_SUBMIT' => 'now_playing' => 'np', {'artist' => 'ArtistName', 'title' => 'TrackTitle'}, # params of now_playing 'job_id' );
See params of now_playing in Net::LastFM::Submission.
$_[KERNEL]->post( 'LASTFM_SUBMIT' => 'submit' => 'sb', {'artist' => 'ArtistName', 'title' => 'TrackTitle', 'time' => time - 10*60}, # params of submit 'job_id' );
See params of submit in Net::LastFM::Submission.
The module supports trace mode - trace POE session.
BEGIN { $ENV{SUBMISSION_TRACE}++ }; use POE::Component::Net::LastFM::Submission;
See examples/poe*.pl in this distributive.
POE Net::LastFM::Submission
Net::LastFM::Submission POE::Component::Client::HTTP POE::Session Carp
Anatoly Sharifulin, <sharifulin at gmail.com>
<sharifulin at gmail.com>
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.
bug-net-lastfm-submission at rt.cpan.org
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
http://annocpan.org/dist/Net-LastFM-Submission
CPANTS: CPAN Testing Service
http://cpants.perl.org/dist/overview/Net-LastFM-Submission
CPAN Ratings
http://cpanratings.perl.org/d/Net-LastFM-Submission
Search CPAN
http://search.cpan.org/dist/Net-LastFM-Submission
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.
To install Net::LastFM::Submission, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::LastFM::Submission
CPAN shell
perl -MCPAN -e shell install Net::LastFM::Submission
For more information on module installation, please visit the detailed CPAN module installation guide.