GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  ANYEVENT::MPRPC::SERVER (3)

.ds Aq ’

NAME

AnyEvent::MPRPC::Server - Simple TCP-based MessagePack RPC server

CONTENTS

SYNOPSIS



    use AnyEvent::MPRPC::Server;
   
    my $server = AnyEvent::MPRPC::Server->new( port => 4423 );
    $server->reg_cb(
        echo => sub {
            my ($res_cv, @params) = @_;
            $res_cv->result(@params);
        },
        sum => sub {
            my ($res_cv, @params) = @_;
            $res_cv->result( $params[0] + $params[1] );
        },
    );



DESCRIPTION

This module is server part of AnyEvent::MPRPC.

METHOD

new (%options)

Create server object, start listening socket, and return object.



    my $server = AnyEvent::MPRPC::Server->new(
        port => 4423,
    );



Available %options are:
port => ’Int | Str’ Listening port or path to unix socket (Required)
address => ’Str’ Bind address. Default to undef: This means server binds all interfaces by default.

If you want to use unix socket, this option should be set to unix/

on_error => $cb->($handle, $fatal, $message) Error callback which is called when some errors occured. This is actually AnyEvent::Handle’s on_error.
on_eof => $cb->($handle) EOF callback. same as AnyEvent::Handle’s on_eof callback.
on_accept => $cb->($fh, $host, $port)
on_dispatch => $cb->($indicator, $handle, $request);
handler_options => ’HashRef’ Hashref options of AnyEvent::Handle that is used to handle client connections.

    reg_cb (%callbacks)

Register MessagePack RPC methods.



    $server->reg_cb(
        echo => sub {
            my ($res_cv, @params) = @_;
            $res_cv->result(@params);
        },
        sum => sub {
            my ($res_cv, @params) = @_;
            $res_cv->result( $params[0] + $params[1] );
        },
    );



callback arguments

MessagePack RPC callback arguments consists of $result_cv, and request @params.



    my ($result_cv, @params) = @_;



$result_cv is AnyEvent::MPRPC::CondVar object. Callback must be call <$result_cv-result>> to return result or <$result_cv-error>> to return error.

If $result_cv is not defined, it is notify request, so you don’t have to return response. See AnyEvent::MPRPC::Client notify method.

@params is same as request parameter.

AUTHOR

Tokuhiro Matsuno <tokuhirom@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2009 by tokuhirom.

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.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 ANYEVENT::MPRPC::SERVER (3) 2012-09-11

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.