The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

AnyEvent::JSONRPC::Lite::Client - Simple TCP-based JSONRPC client

SYNOPSIS

    use AnyEvent::JSONRPC::Lite::Client;
    
    my $client = AnyEvent::JSONRPC::Lite::Client->new(
        host => '127.0.0.1',
        port => 4423,
    );
    
    my $cv = $client->call('echo', 'foo', 'bar');
    
    my $res    = $cv->recv;
    my $result = $res->{result}; # => ['foo', 'bar']

DESCRIPTION

This module is client part of AnyEvent::JSONRPC::Lite.

METHODS

new (%options)

Create new client object and return it.

    my $client = AnyEvent::JSONRPC::Lite::Client->new(
        host => '127.0.0.1',
        port => 4423,
    );

Available options are:

host (Required)

Hostname to connect.

port (Required)

Port number to connect.

handler_options (Optional)

Hashref. This is passed to constructor of AnyEvent::Handle that is used manage connection.

call ($method, @params)

Call remote method named $method with parameters @params. And return condvar object for response.

    my $cv = $client->call( echo => 'Hello!' );
    my $res = $cv->recv;

notify ($method, @params)

Same as call method, but not handle response. This method just notify to server.

    $client->call( echo => 'Hello' );

AUTHOR

Daisuke Murase <typester@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2009 by KAYAC Inc.

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.