Skip to content

Instantly share code, notes, and snippets.

@mattvv
Created October 11, 2012 00:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattvv/3869317 to your computer and use it in GitHub Desktop.
Save mattvv/3869317 to your computer and use it in GitHub Desktop.
Check if a Subscriber is on a call for SipWise
=item B<check_live> { $username, $domain, \%data }
=back
=over
Checks if a certain subscriber is on a call. Returns true if they are and false if they are not.
=back
=cut
sub check_live {
my $self = shift;
my $data = shift;
$self->_require_userdom($data);
$self->_check_subscriber_data($$data{data});
my $dispatcher = Sipwise::Provisioning::XMLDispatcher->new;
my @results = $dispatcher->dispatch("proxy-ng", 1, 1, <<EOF);
<?xml version="1.0" ?>
<methodCall>
<methodName>dlg.list</methodName>
<params/>
</methodCall>
EOF
my $result = @results[0]->[2];
my $substring = "$$data{username}\@$$data{domain}";
if (index($result, $substring) != -1) {
return "true";
}
return "false";
}
... later on
elsif($function eq 'check_bool'
or $function eq 'check_username'
or $function eq 'check_ip'
or $function eq 'check_ip4'
or $function eq 'check_ip6'
or $function eq 'check_ip6_brackets'
or $function eq 'check_ipnet'
or $function eq 'check_domain'
or $function eq 'check_sip_uri'
or $function eq 'check_sip_uri_pattern'
or $function eq 'check_sip_uri_prefix'
or $function eq 'check_sip_username'
or $function eq 'check_email'
or $function eq 'check_cc'
or $function eq 'check_ac'
or $function eq 'check_sn'
or $function eq 'check_E164_number'
or $function eq 'check_E164_shell_pattern'
or $function eq 'check_sip_username_shell_pattern'
or $function eq 'check_vsc_format'
or $function eq 'check_date'
or $function eq 'check_time'
or $function eq 'check_timestamp'
or $function eq 'check_sip_transport_protocol'
or $function eq 'get_localized_string'
or $function eq 'check_selected_enum'
or $function eq 'check_regex_syntax'
or $function eq 'check_localpart'
or $function eq 'check_live'
)
sub check_live { typed $Voip->handle_request('check_live', pop) }
@mattvv
Copy link
Author

mattvv commented Jan 2, 2013

Thanks Daniel! Any Idea on when this can be shipped with Sipwise also and not just a patch?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment