| 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
|
|
335094
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
103
|
|
|
8
|
4
|
|
|
4
|
|
14
|
use warnings; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
102
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use base qw( Net::Async::Tangence::Server ); |
|
|
4
|
|
|
|
|
5
|
|
|
|
4
|
|
|
|
|
2101
|
|
|
10
|
|
|
|
|
|
|
IO::Async::Notifier->VERSION( '0.43' ); # ->loop |
|
11
|
|
|
|
|
|
|
Net::Async::Tangence::Server->VERSION( '0.12' ); # subclass of IaListener |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.170740'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
4
|
|
|
4
|
|
355769
|
use Carp; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
206
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
1951
|
use Tangence::Registry 0.20; # Support for late-loading classes |
|
|
4
|
|
|
|
|
74126
|
|
|
|
4
|
|
|
|
|
173
|
|
|
18
|
4
|
|
|
4
|
|
2214
|
use Circle::RootObj; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use File::ShareDir qw( module_file ); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use IO::Async::OS; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
C - server backend for the C application host |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub new |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
|
|
|
|
|
|
my $class = shift; |
|
33
|
|
|
|
|
|
|
my %args = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $loop = $args{loop} or croak "Need a loop"; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $registry = Tangence::Registry->new( |
|
38
|
|
|
|
|
|
|
tanfile => module_file( __PACKAGE__, "circle.tan" ), |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $rootobj = $registry->construct( |
|
42
|
|
|
|
|
|
|
"Circle::RootObj", |
|
43
|
|
|
|
|
|
|
loop => $loop |
|
44
|
|
|
|
|
|
|
); |
|
45
|
|
|
|
|
|
|
$rootobj->id == 1 or die "Assert failed: root object does not have ID 1"; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $self = $class->SUPER::new( |
|
48
|
|
|
|
|
|
|
registry => $registry, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
$loop->add( $self ); |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$self->{rootobj} = $rootobj; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return $self; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_local_client |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
my $self = shift; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $loop = $self->loop; |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my ( $S1, $S2 ) = IO::Async::OS->socketpair or die "Cannot socketpair - $!"; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Internal hackery; stolen from IaListener |
|
67
|
|
|
|
|
|
|
my $acceptor = $self->acceptor; |
|
68
|
|
|
|
|
|
|
my $handle = $self->{new_handle}->( $self ); |
|
69
|
|
|
|
|
|
|
$S1->blocking( 0 ); |
|
70
|
|
|
|
|
|
|
$handle->set_handle( $S1 ); |
|
71
|
|
|
|
|
|
|
$self->on_accept( $handle ); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
require Net::Async::Tangence::Client; |
|
74
|
|
|
|
|
|
|
my $client = Net::Async::Tangence::Client->new( |
|
75
|
|
|
|
|
|
|
handle => $S2, |
|
76
|
|
|
|
|
|
|
identity => "test_client", |
|
77
|
|
|
|
|
|
|
); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$loop->add( $client ); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
return $client; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub new_with_client |
|
85
|
|
|
|
|
|
|
{ |
|
86
|
|
|
|
|
|
|
my $class = shift; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $self = $class->new( @_ ); |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
my $client = $self->make_local_client; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return ( $self, $client ); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub warn |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
|
|
|
|
|
|
my $self = shift; |
|
98
|
|
|
|
|
|
|
my $text = join " ", @_; |
|
99
|
|
|
|
|
|
|
chomp $text; |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
my $rootobj = $self->{rootobj}; |
|
102
|
|
|
|
|
|
|
$rootobj->push_displayevent( warning => { text => $text } ); |
|
103
|
|
|
|
|
|
|
$rootobj->bump_level( 2 ); |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Paul Evans |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
0x55AA; |