| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package QxExample::JsonRpcService; |
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use Mojo::Base -base; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
JsonRpcService - RPC services for Qooxdoo |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
This module gets instanciated by L and provides backend functionality for your qooxdoo app |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
All methods on this class can get called remotely as long as their name does not start with an underscore. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head2 new() |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Create a service object. |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
|
24
|
1
|
|
|
1
|
1
|
7
|
my $self = shift->SUPER::new(@_); |
|
25
|
|
|
|
|
|
|
# do some other interesting initialization work |
|
26
|
1
|
|
|
|
|
8
|
return $self; |
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 allow_rpc_access |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
check it this method may be called |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our %allow_access = ( |
|
36
|
|
|
|
|
|
|
echo => 1 |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub allow_rpc_access { |
|
40
|
4
|
|
|
4
|
1
|
6
|
my $self = shift; |
|
41
|
4
|
|
|
|
|
9
|
my $method = shift; |
|
42
|
4
|
|
|
|
|
28
|
return $allow_access{$method}; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 echo(var) |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return the string we input |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=cut |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub echo { |
|
52
|
3
|
|
|
3
|
1
|
6
|
my $self = shift; |
|
53
|
3
|
100
|
|
|
|
23
|
my $arg = shift or die QxExample::Exception->new(code=>123,message=>"Argument Required!"); |
|
54
|
2
|
|
|
|
|
8
|
return $arg; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
package QxExample::Exception; |
|
58
|
1
|
|
|
1
|
|
312
|
use Mojo::Base -base; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
4
|
|
|
59
|
|
|
|
|
|
|
has 'code'; |
|
60
|
|
|
|
|
|
|
has 'message'; |
|
61
|
1
|
|
|
1
|
|
100
|
use overload ('""' => 'stringify'); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
9
|
|
|
62
|
|
|
|
|
|
|
sub stringify { |
|
63
|
2
|
|
|
2
|
|
50
|
my $self = shift; |
|
64
|
2
|
|
|
|
|
53
|
return "ERROR ".$self->code.": ".$self->message; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
|
68
|
|
|
|
|
|
|
__END__ |