Ser::BinRPC - Perl extension for Ser SIP router controlling via BinRPC protocol
use Ser::BinRPC;
Ser::BinRPC provides an object interface to controlling SER (Sip Express Router) or SIP-Router (http://www.sip-router.org) via binary RPC (BinRPC) protocol. The BinRPC is light-weighted RPC protocol provided by ctl module. Unix, UDP and TCP network protocols are supported.
The constructor takes no arguments. Assign default field values.
Print more verbose messages at STDERR. Default: 0
Type of socket domain (PF_UNIX .. default, PF_INET)
Socket type (SOCK_STREAM .. default, SOCK_DGRAM)
Name of remote socket, default: '/tmp/ser_ctl'
Name of remote host for UDP/TCP connection, default: 'localhost'
Port for UDP/TCP connection, default: 2049
Protocol ('udp'..default, 'tcp')
If a method fails then returns 0 and reason is stored in errs field.
Parse connection string, syntax:
"unix" [ ":" [ unix_sock ] ] ("tcp" | "udp") [ ":" [ remote_host ] ":" [ remote_port ] ]
If a value is omited then current value remains unchanged. Example:
$self->parse_connection_string('udp:127.0.0.2:2050'); $self->parse_connection_string('unix:/tmp/ser_ctl2');
Open socket connection.
Close socket connection.
Do RPC command and get result. If OK then returns 1, if RPC server returns error code then return value is -1. Result contains array of values (scalar, array, hash). Values may be nested.
Example:
use Socket; use Ser::BinRPC; my $conn = Ser::BinRPC->new(); $conn->{domain} = PF_INET; $conn->{remote_host} = 'localhost'; $conn->{remote_port} = 2050; $conn->{proto} = 'tcp'; $conn->{sock_type} = SOCK_STREAM; # or # $conn->parse_connection_string('tcp:localhost:2050'); my $ret = $conn->command('core.uptime', [ ], \@result); if ($ret > 0) { $conn->print_result(\*STDERR, \@result); printf("Server uptime is %d\n", $res[0]->{'uptime'}); } elsif ($ret < 0) { # RPC error printf STDERR "%d - %s", $result[0], $result[1]; } else { die $conn->{errs}; }
Print result in human readable form.
None by default.
SER: http://www.iptel.org/ser/, SIP-Router: http://www.sip-router.org
Tomas Mandys, <lt>tomas.mandys@2p.cz<gt>
Copyright (C) 2010 by Tomas Mandys
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Ser::BinRPC, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ser::BinRPC
CPAN shell
perl -MCPAN -e shell install Ser::BinRPC
For more information on module installation, please visit the detailed CPAN module installation guide.