line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of the GNU General Public License |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# (C) Paul Evans, 2008-2014 -- leonerd@leonerd.org.uk |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Circle; |
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
307059
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
165
|
|
8
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
156
|
|
9
|
4
|
|
|
4
|
|
35
|
use base qw( Net::Async::Tangence::Server ); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
5136
|
|
10
|
|
|
|
|
|
|
IO::Async::Notifier->VERSION( '0.43' ); # ->loop |
11
|
|
|
|
|
|
|
Net::Async::Tangence::Server->VERSION( '0.12' ); # subclass of IaListener |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.142470'; |
14
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
625241
|
use Carp; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
236
|
|
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
3763
|
use Tangence::Registry 0.20; # Support for late-loading classes |
|
4
|
|
|
|
|
100758
|
|
|
4
|
|
|
|
|
224
|
|
18
|
4
|
|
|
4
|
|
3305
|
use Circle::RootObj; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
213
|
|
19
|
|
|
|
|
|
|
|
20
|
4
|
|
|
4
|
|
6807
|
use File::ShareDir qw( module_file ); |
|
4
|
|
|
|
|
34982
|
|
|
4
|
|
|
|
|
381
|
|
21
|
|
|
|
|
|
|
|
22
|
4
|
|
|
4
|
|
49
|
use IO::Async::OS; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
1771
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
C - server backend for the C application host |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new |
31
|
|
|
|
|
|
|
{ |
32
|
3
|
|
|
3
|
1
|
7
|
my $class = shift; |
33
|
3
|
|
|
|
|
15
|
my %args = @_; |
34
|
|
|
|
|
|
|
|
35
|
3
|
50
|
|
|
|
19
|
my $loop = $args{loop} or croak "Need a loop"; |
36
|
|
|
|
|
|
|
|
37
|
3
|
|
|
|
|
22
|
my $registry = Tangence::Registry->new( |
38
|
|
|
|
|
|
|
tanfile => module_file( __PACKAGE__, "circle.tan" ), |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
196317
|
my $rootobj = $registry->construct( |
42
|
|
|
|
|
|
|
"Circle::RootObj", |
43
|
|
|
|
|
|
|
loop => $loop |
44
|
|
|
|
|
|
|
); |
45
|
3
|
50
|
|
|
|
465
|
$rootobj->id == 1 or die "Assert failed: root object does not have ID 1"; |
46
|
|
|
|
|
|
|
|
47
|
3
|
|
|
|
|
92
|
my $self = $class->SUPER::new( |
48
|
|
|
|
|
|
|
registry => $registry, |
49
|
|
|
|
|
|
|
); |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
|
|
500
|
$loop->add( $self ); |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
407
|
$self->{rootobj} = $rootobj; |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
12
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_local_client |
59
|
|
|
|
|
|
|
{ |
60
|
3
|
|
|
3
|
0
|
16
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
11
|
my $loop = $self->loop; |
63
|
|
|
|
|
|
|
|
64
|
3
|
50
|
|
|
|
60
|
my ( $S1, $S2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!"; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Internal hackery; stolen from IaListener |
67
|
3
|
|
|
|
|
1054
|
my $acceptor = $self->acceptor; |
68
|
3
|
|
|
|
|
26
|
my $handle = $self->{new_handle}->( $self ); |
69
|
3
|
|
|
|
|
806
|
$S1->blocking( 0 ); |
70
|
3
|
|
|
|
|
87
|
$handle->set_handle( $S1 ); |
71
|
3
|
|
|
|
|
642
|
$self->on_accept( $handle ); |
72
|
|
|
|
|
|
|
|
73
|
3
|
|
|
|
|
4403
|
require Net::Async::Tangence::Client; |
74
|
3
|
|
|
|
|
55481
|
my $client = Net::Async::Tangence::Client->new( |
75
|
|
|
|
|
|
|
handle => $S2, |
76
|
|
|
|
|
|
|
identity => "test_client", |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
3
|
|
|
|
|
2100
|
$loop->add( $client ); |
80
|
|
|
|
|
|
|
|
81
|
3
|
|
|
|
|
974
|
return $client; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub new_with_client |
85
|
|
|
|
|
|
|
{ |
86
|
3
|
|
|
3
|
0
|
15223
|
my $class = shift; |
87
|
|
|
|
|
|
|
|
88
|
3
|
|
|
|
|
23
|
my $self = $class->new( @_ ); |
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
15
|
my $client = $self->make_local_client; |
91
|
|
|
|
|
|
|
|
92
|
3
|
|
|
|
|
18
|
return ( $self, $client ); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub warn |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
my $text = join " ", @_; |
99
|
0
|
|
|
|
|
|
chomp $text; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
my $rootobj = $self->{rootobj}; |
102
|
0
|
|
|
|
|
|
$rootobj->push_displayevent( warning => { text => $text } ); |
103
|
0
|
|
|
|
|
|
$rootobj->bump_level( 2 ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Paul Evans |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
0x55AA; |