NAME

AnyEvent::JSONRPC - Simple TCP-based JSONRPC client/server

SYNOPSIS

use AnyEvent::JSONRPC;

my $server = jsonrpc_server '127.0.0.1', '4423';
$server->reg_cb(
    echo => sub {
        my ($res_cv, @params) = @_;
        $res_cv->result(@params);
    },
);

my $client = jsonrpc_client '127.0.0.1', '4423';
my $d = $client->call( echo => 'foo bar' );

my $res = $d->recv; # => 'foo bar';

DESCRIPTION

This module provide TCP-based JSONRPC server/client implementation.

AnyEvent::JSONRPC provide you a couple of export functions that are shortcut of AnyEvent::JSONRPC::TCP::Client and AnyEvent::JSONRPC::TCP::Server. One is jsonrpc_client for Client, another is jsonrpc_server for Server.

DIFFERENCES FROM THE "Lite" MODULE

This module is a fork of Daisuke Murase's AnyEvent::JSONRPC::Lite updated to use Yuval Kogman's JSON::RPC::Common for handling the JSONRPC messages. This enables support for handling messages complying to all versions of the JSONRPC standard.

The System Services/Service Description parts of version 1.1-wd and 1.1-alt is unimplemented and left to users to implement.

As none of the specs really defines JSON-RPC over TCP I consider this module an otherwise full-spec implementation.

FUNCTIONS

jsonrpc_server $address, $port;

Create AnyEvent::JSONRPC::TCP::Server object and return it.

This is equivalent to:

AnyEvent::JSONRPC::TCP::Server->new(
    address => $address,
    port    => $port,
);

See AnyEvent::JSONRPC::TCP::Server for more detail.

jsonrpc_client $hostname, $port

Create AnyEvent::JSONRPC::TCP::Client object and return it.

This is equivalent to:

AnyEvent::JSONRPC::TCP::Client->new(
    host => $hostname,
    port => $port,
);

See AnyEvent::JSONRPC::TCP::Client for more detail.

SEE ALSO

AnyEvent, AnyEvent::JSONRPC::Lite, JSON::RPC::Common.

http://json-rpc.org/

AUTHOR

Peter Makholm <peter@makholm.net>

COPYRIGHT AND LICENSE

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.