Catalyst-Model-JabberRPC
view release on metacpan or search on metacpan
lib/Catalyst/Helper/Model/JabberRPC.pm view on Meta::CPAN
=item * C<myserver.org>
The same as the B<server> arg. passed to L<Jabber::RPC::Client>.
=item * C<user:password>
The same as the B<identauth> arg. passed to L<Jabber::RPC::Client>.
=item * C<jrpc.myserver.org/rpc-server>
The same as the B<endpoint> arg. passed to L<Jabber::RPC::Client>.
=back
=head1 METHODS
=head2 mk_compclass
Makes the JabberRPC model class.
=cut
sub mk_compclass {
my ($self, $helper, $server, $identauth, $endpoint) = @_;
$helper->{server} = $server || '';
$helper->{identauth} = $identauth || '';
$helper->{endpoint} = $endpoint || '';
$helper->render_file('modelclass', $helper->{file});
return 1;
}
=head2 mk_comptest
Makes tests for the JabberRPC model.
lib/Catalyst/Helper/Model/JabberRPC.pm view on Meta::CPAN
__modelclass__
package [% class %];
use strict;
use warnings;
use base 'Catalyst::Model::JabberRPC';
__PACKAGE__->config(
server => '[% server %]',
identauth => '[% identauth %]',
endpoint => '[% endpoint %]',
# For more options take a look at L<Jabber::RPC::Client>.
);
=head1 NAME
[% class %] - JabberRPC Catalyst model component
=head1 SYNOPSIS
See L<[% app %]>.
lib/Catalyst/Model/JabberRPC.pm view on Meta::CPAN
sub new {
my ($class, $c, $config) = @_;
my $self = $class->NEXT::new($c, $config);
$self->config($config);
my %jabber_config = %{ $self->config };
for my $key (qw/server identauth endpoint/) {
croak "Must provide $key" unless exists $jabber_config{$key};
}
my $client = Jabber::RPC::Client->new(%jabber_config);
croak "Can't create Jabber::RPC::Client object"
unless UNIVERSAL::isa($client, 'Jabber::RPC::Client');
$self->{jabber_client} = $client;
$c->log->debug("New Jabber::RPC::Client created") if $c->debug;
lib/Catalyst/Model/JabberRPC.pm view on Meta::CPAN
=head1 NAME
Catalyst::Model::JabberRPC - JabberRPC model class for Catalyst
=head1 SYNOPSIS
# Model
__PACKAGE__->config(
server => 'myserver.org',
identauth => 'user:password',
endpoint => 'jrpc.myserver.org/rpc-server',
);
# Controller
sub default : Private {
my ($self, $c) = @_;
my $result;
eval {
$result = $c->model('RemoteService')->call('examples.getStateName', 5);
( run in 1.147 second using v1.01-cache-2.11-cpan-b61123c0432 )