line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Lim::RPC::Callback; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
11613
|
use common::sense; |
|
3
|
|
|
|
|
21
|
|
|
3
|
|
|
|
|
27
|
|
4
|
3
|
|
|
3
|
|
163
|
use Carp; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
893
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
370
|
use Log::Log4perl (); |
|
3
|
|
|
|
|
21
|
|
|
3
|
|
|
|
|
60
|
|
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
19
|
use Lim (); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2204
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=encoding utf8 |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Lim::RPC::Callback - Base class of all RPC callbacks |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 VERSION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
See L for version. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=over 4 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package Lim::RPC::Callback::MyCallback; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use base qw(Lim::RPC::Callback); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=back |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 4 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=item $callback = Lim::RPC::Callback::MyCallback->new(key => value...) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Create a new callback object. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=over 4 |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item cb => $callback (required) |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Set the callback function related to this callback. This is set by |
45
|
|
|
|
|
|
|
L depending on what protocol in incoming. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item client => $client (required) |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Set the L related to this callback. This is set by |
50
|
|
|
|
|
|
|
L on incoming calls. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new { |
57
|
4
|
|
|
4
|
1
|
11
|
my $this = shift; |
58
|
4
|
|
33
|
|
|
27
|
my $class = ref($this) || $this; |
59
|
4
|
|
|
|
|
20
|
my %args = ( @_ ); |
60
|
4
|
|
|
|
|
41
|
my $self = { |
61
|
|
|
|
|
|
|
logger => Log::Log4perl->get_logger |
62
|
|
|
|
|
|
|
}; |
63
|
4
|
|
|
|
|
1067
|
bless $self, $class; |
64
|
|
|
|
|
|
|
|
65
|
4
|
50
|
33
|
|
|
40
|
unless (defined $args{cb} and ref($args{cb}) eq 'CODE') { |
66
|
0
|
|
|
|
|
0
|
confess __PACKAGE__, ': cb not given or invalid'; |
67
|
|
|
|
|
|
|
} |
68
|
4
|
50
|
33
|
|
|
125
|
unless (defined $args{reset_timeout} and ref($args{reset_timeout}) eq 'CODE') { |
69
|
0
|
|
|
|
|
0
|
confess __PACKAGE__, ': reset_timeout not given or invalid'; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
4
|
|
|
|
|
29
|
$self->{cb} = $args{cb}; |
73
|
4
|
|
|
|
|
12
|
$self->{reset_timeout} = $args{reset_timeout}; |
74
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
20
|
$self->Init(@_); |
76
|
|
|
|
|
|
|
|
77
|
4
|
50
|
|
|
|
22
|
Lim::OBJ_DEBUG and $self->{logger}->debug('new ', __PACKAGE__, ' ', $self); |
78
|
4
|
|
|
|
|
2107
|
$self; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub DESTROY { |
82
|
4
|
|
|
4
|
|
10
|
my ($self) = @_; |
83
|
|
|
|
|
|
|
|
84
|
4
|
|
|
|
|
19
|
$self->Destroy; |
85
|
|
|
|
|
|
|
|
86
|
4
|
50
|
|
|
|
24
|
Lim::OBJ_DEBUG and $self->{logger}->debug('destroy ', __PACKAGE__, ' ', $self); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item $callback->Init(...) |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Called from C on object creation with the same arguments as passed to |
92
|
|
|
|
|
|
|
C. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Should be overloaded if you wish to do initial things on creation. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
4
|
|
|
4
|
1
|
9
|
sub Init { |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item $callback->Destroy(...) |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Called from C on object destruction. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Should be overloaded if you wish to do things on destruction. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
4
|
|
|
4
|
1
|
7
|
sub Destroy { |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item $callback->cb |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Return the callback. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub cb { |
119
|
4
|
|
|
4
|
1
|
29
|
$_[0]->{cb}; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item $callback->call_def |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Return the call definition set by C. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=cut |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub call_def { |
129
|
6
|
|
|
6
|
1
|
62
|
$_[0]->{call_def}; |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item $callback->set_call_def |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Set the call definition related to this callback. Returns the references to it |
135
|
|
|
|
|
|
|
self. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub set_call_def { |
140
|
2
|
50
|
|
2
|
1
|
12
|
if (ref($_[1]) eq 'HASH') { |
141
|
2
|
|
|
|
|
9
|
$_[0]->{call_def} = $_[1]; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
2
|
|
|
|
|
6
|
$_[0]; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item $callback->reset_timeout |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Reset the timeout of the client related to this callback. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub reset_timeout { |
154
|
0
|
|
|
0
|
1
|
|
$_[0]->{reset_timeout}->(); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 AUTHOR |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Jerry Lundström, C<< >> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 BUGS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Please report any bugs or feature requests to L. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 SUPPORT |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
perldoc Lim::RPC::Callback |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
You can also look for information at: |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over 4 |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * Lim issue tracker (report bugs here) |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
L |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=back |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Copyright 2012-2013 Jerry Lundström. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
190
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
191
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=cut |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
1; # End of Lim::RPC::Callback |