« blib/lib/Beekeeper/JSONRPC/Response.pm
↑ Summary
blib/lib/auto/share/dist/Beekeeper/basic/client.pl »
| 1 | package Beekeeper::Worker::Extension::RemoteSession; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | our $VERSION = '0.09'; | ||
| 7 | |||
| 8 | use Exporter 'import'; | ||
| 9 | |||
| 10 | our @EXPORT = qw( | ||
| 11 | bind_remote_session | ||
| 12 | unbind_remote_session | ||
| 13 | unbind_remote_address | ||
| 14 | ); | ||
| 15 | |||
| 16 | # Show errors from perspective of caller | ||
| 17 | $Carp::Internal{(__PACKAGE__)}++; | ||
| 18 | |||
| 19 | |||
| 20 | sub bind_remote_session { | ||
| 21 | my ($self, %args) = @_; | ||
| 22 | |||
| 23 | my $params = { | ||
| 24 | address => $args{'address'}, | ||
| 25 | caller_id => $self->{_CLIENT}->{caller_id}, | ||
| 26 | caller_addr => $self->{_CLIENT}->{caller_addr}, | ||
| 27 | auth_data => $self->{_CLIENT}->{auth_data}, | ||
| 28 | }; | ||
| 29 | |||
| 30 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 31 | |||
| 32 | $self->call_remote( | ||
| 33 | method => '_bkpr.router.bind', | ||
| 34 | params => $params, | ||
| 35 | timeout => $args{'timeout'}, | ||
| 36 | ); | ||
| 37 | } | ||
| 38 | |||
| 39 | sub bind_remote_session_async { | ||
| 40 | my ($self, %args) = @_; | ||
| 41 | |||
| 42 | my $params = { | ||
| 43 | address => $args{'address'}, | ||
| 44 | caller_id => $self->{_CLIENT}->{caller_id}, | ||
| 45 | caller_addr => $self->{_CLIENT}->{caller_addr}, | ||
| 46 | auth_data => $self->{_CLIENT}->{auth_data}, | ||
| 47 | }; | ||
| 48 | |||
| 49 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 50 | |||
| 51 | $self->call_remote_async( | ||
| 52 | method => '_bkpr.router.bind', | ||
| 53 | params => $params, | ||
| 54 | timeout => $args{'timeout'}, | ||
| 55 | on_success => $args{'on_success'}, | ||
| 56 | on_error => $args{'on_error'}, | ||
| 57 | ); | ||
| 58 | } | ||
| 59 | |||
| 60 | sub unbind_remote_session { | ||
| 61 | my ($self, %args) = @_; | ||
| 62 | |||
| 63 | my $params = { caller_id => $self->{_CLIENT}->{caller_id} }; | ||
| 64 | |||
| 65 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 66 | |||
| 67 | $self->call_remote( | ||
| 68 | method => '_bkpr.router.unbind', | ||
| 69 | params => $params, | ||
| 70 | timeout => $args{'timeout'}, | ||
| 71 | ); | ||
| 72 | } | ||
| 73 | |||
| 74 | sub unbind_remote_session_async { | ||
| 75 | my ($self, %args) = @_; | ||
| 76 | |||
| 77 | my $params = { caller_id => $self->{_CLIENT}->{caller_id} }; | ||
| 78 | |||
| 79 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 80 | |||
| 81 | $self->call_remote_async( | ||
| 82 | method => '_bkpr.router.unbind', | ||
| 83 | params => $params, | ||
| 84 | timeout => $args{'timeout'}, | ||
| 85 | on_success => $args{'on_success'}, | ||
| 86 | on_error => $args{'on_error'}, | ||
| 87 | ); | ||
| 88 | } | ||
| 89 | |||
| 90 | sub unbind_remote_address { | ||
| 91 | my ($self, %args) = @_; | ||
| 92 | |||
| 93 | my $params = { address => $args{'address'} }; | ||
| 94 | |||
| 95 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 96 | |||
| 97 | $self->call_remote( | ||
| 98 | method => '_bkpr.router.unbind', | ||
| 99 | params => $params, | ||
| 100 | timeout => $args{'timeout'}, | ||
| 101 | ); | ||
| 102 | } | ||
| 103 | |||
| 104 | sub unbind_remote_address_async { | ||
| 105 | my ($self, %args) = @_; | ||
| 106 | |||
| 107 | my $params = { address => $args{'address'} }; | ||
| 108 | |||
| 109 | my $guard = $self->__use_authorization_token('BKPR_ROUTER'); | ||
| 110 | |||
| 111 | $self->call_remote_async( | ||
| 112 | method => '_bkpr.router.unbind', | ||
| 113 | params => $params, | ||
| 114 | timeout => $args{'timeout'}, | ||
| 115 | on_success => $args{'on_success'}, | ||
| 116 | on_error => $args{'on_error'}, | ||
| 117 | ); | ||
| 118 | } | ||
| 119 | |||
| 120 | 1; | ||
| 121 | |||
| 122 | __END__ |