AnyEvent::JSONRPC::Utils - Helper functions for use with AnyEvent::JSONRPC
# XXX being either TCP or HTTP my $server = AnyEvent::JSONRPC::XXX::Server->new(); # Delegate methods to an object: my $object = Foo->new(); $server->reg_cb( method1 => delegate($object), ); # Delegate methods to another json-rpc server my $client = AnyEvent::JSONRPC::XXX::Client->new(); $server->reg_cb( method2 => delegate($client), ); # Delegate all methods from moose object my $object = Bar->new(); $server->reg_cb( do_moose($object), );
This module provides a couple of helper functions for creating JSON-RPC servers. This is kind of experimental at the moment.
delegate <$object>
This function returns a generic subroutine usable for registering method calls. The same subroutine can be used for registering multiple methods delegated to the same object.
If $object is a AnyEvent::JSONRPC client method calls will be proxied through this client, otherwise it is assumed to be method calls on the object.
$object
do_moose <$object>
This function returns a complete delegation of methods to a Moose object. Some methods are considered protected and should be explicitly registered if needed. This includes all method names starting with an underscore, all methodnames consisting of only capital letters, and the following methods generated by Moose: new, meta, dump, and does.
new
meta
dump
does
Peter Makholm <peter@makholm.net>
Copyright (c) 2010 by Peter Makholm.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install AnyEvent::JSONRPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::JSONRPC
CPAN shell
perl -MCPAN -e shell install AnyEvent::JSONRPC
For more information on module installation, please visit the detailed CPAN module installation guide.