Tomáš Mandys > Ser-BinRPC-0.01 > Ser::BinRPC

Download:
Ser-BinRPC-0.01.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.01   Source  

NAME ^

Ser::BinRPC - Perl extension for Ser SIP router controlling via BinRPC protocol

SYNOPSIS ^

  use Ser::BinRPC;

DESCRIPTION ^

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.

CONSTRUCTOR ^

new ()

The constructor takes no arguments. Assign default field values.

FIELDS ^

verbose

Print more verbose messages at STDERR. Default: 0

sock_domain

Type of socket domain (PF_UNIX .. default, PF_INET)

sock_type

Socket type (SOCK_STREAM .. default, SOCK_DGRAM)

unix_sock

Name of remote socket, default: '/tmp/ser_ctl'

remote_host

Name of remote host for UDP/TCP connection, default: 'localhost'

remote_port

Port for UDP/TCP connection, default: 2049

proto

Protocol ('udp'..default, 'tcp')

errs

If a method fails then returns 0 and reason is stored in errs field.

METHODS ^

parse_connection_string ($string)

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 ()

Open socket connection.

close ()

Close socket connection.

command ( $cmd , \@cmd_params, \@result )

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 ( \*STREAM, \@result, [$prefix] )

Print result in human readable form.

EXPORT

None by default.

SEE ALSO ^

SER: http://www.iptel.org/ser/, SIP-Router: http://www.sip-router.org

AUTHOR ^

Tomas Mandys, <lt>tomas.mandys@2p.cz<gt>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: