![]() |
![]()
| ![]() |
![]()
NAMEAnyEvent::MPRPC::Server - Simple TCP-based MessagePack RPC serverSYNOPSISuse 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] ); }, ); DESCRIPTIONThis module is server part of AnyEvent::MPRPC.METHODnew (%options)Create server object, start listening socket, and return object.my $server = AnyEvent::MPRPC::Server->new( port => 4423, ); Available %options are:
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. AUTHORTokuhiro Matsuno <tokuhirom@cpan.org>COPYRIGHT AND LICENSECopyright (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.
|