AnyEvent-XMLRPC
view release on metacpan or search on metacpan
lib/AnyEvent/XMLRPC.pm view on Meta::CPAN
Version 0.05
=cut
our $VERSION = '0.05';
=head1 SYNOPSIS
use AnyEvent::XMLRPC;
my $serv = AnyEvent::XMLRPC->new(
methods => {
'echo' => \&echo,
},
);
or
my $serv = AnyEvent::XMLRPC->new(
port => 9090,
uri => "/RPC2",
methods => {
'echo' => \&echo,
},
);
and
sub echo {
@rep = qw(bala bababa);
return \@rep;
}
$serv->run;
=head1 DESCRIPTION
I<AnyEvent::XMLRPC> is a Non-Blocking XMLRPC Server.
Originally a L<AnyEvent> implementation of L<Frontier>.
I<AnyEvent::XMLRPC> is base on elmex's L<AnyEvent::HTTPD>.
=head1 FUNCTIONS
=head2 new (%options)
=cut
sub new {
my $class = shift;
my %args = @_;
$args{'port'} ||= 9090;
# extract args which are not for httpd
my $methods = delete $args{'methods'};
my $uri = delete $args{'uri'};
$uri ||= "/RPC2";
# get a new clean AnyEvent::HTTPD
my $self = $class->SUPER::new(%args);
return undef unless $self;
# Now I'm AnyEvent::XMLRPC
bless $self, $class;
# register methods, use Frontier::RPC2 to encode/decode xml
${$self}{'methods'} = $methods;
${$self}{'decode'} = new Frontier::RPC2 'use_objects' => $args{'use_objects'};
# register AnyEvent(::HTTPD) callbacks
$self->reg_cb (
'/RPC2' => sub {
my ($httpd, $req) = @_;
#~ my $reply = ${$self}{'decode'}->serve(
#~ $req->content, ${$self}{'methods'}
#~ );
$req->respond ({ content => [
'text/xml',
${$self}{'decode'}->serve(
$req->content, ${$self}{'methods'}
)
]});
$httpd->stop_request;
},
'' => sub {
my ($httpd, $req) = @_;
$req->respond ({ content => ['text/html',
"I'm not something you think I am..."
]});
},
);
return $self;
}
=head1 AUTHOR
BlueT - Matthew Lien - ç·´åæ, C<< <BlueT at BlueT.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-anyevent-xmlrpc at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-XMLRPC>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc AnyEvent::XMLRPC
( run in 0.984 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )