… | |
… | |
31 | |
31 | |
32 | use base "Exporter"; |
32 | use base "Exporter"; |
33 | |
33 | |
34 | our $VERSION = '0.01'; |
34 | our $VERSION = '0.01'; |
35 | our @EXPORT = qw( |
35 | our @EXPORT = qw( |
36 | NODE $NODE snd del _any_ |
36 | NODE $NODE snd kil _any_ |
37 | become_slave become_public |
37 | become_slave become_public |
38 | ); |
38 | ); |
39 | |
39 | |
40 | our $DEFAULT_SECRET; |
40 | our $DEFAULT_SECRET; |
41 | |
41 | |
… | |
… | |
143 | |
143 | |
144 | ($NODE{$noderef} || add_node $noderef) |
144 | ($NODE{$noderef} || add_node $noderef) |
145 | ->send ([$port, @_]); |
145 | ->send ([$port, @_]); |
146 | } |
146 | } |
147 | |
147 | |
148 | sub del($) { |
148 | sub kil($) { |
149 | my ($noderef, $port) = split /#/, shift, 2; |
149 | my ($noderef, $port) = split /#/, shift, 2; |
150 | |
150 | |
151 | delete $PORT{$port}; |
151 | ($NODE{$noderef} || add_node $noderef) |
152 | |
152 | ->kill ($port, @_); |
153 | my $mon = delete $LMON{$port} |
|
|
154 | or return; |
|
|
155 | |
|
|
156 | $_->() for values %$mon; |
|
|
157 | } |
153 | } |
158 | |
154 | |
159 | sub become_public { |
155 | sub become_public { |
160 | return if $PUBLIC; |
156 | return if $PUBLIC; |
161 | |
157 | |
… | |
… | |
196 | }, |
192 | }, |
197 | mon1 => sub { # enable monitoring |
193 | mon1 => sub { # enable monitoring |
198 | my $portid = shift; |
194 | my $portid = shift; |
199 | my $node = $SRCNODE; |
195 | my $node = $SRCNODE; |
200 | $NODE{""}->monitor ($portid, $node->{rmon}{$portid} = sub { |
196 | $NODE{""}->monitor ($portid, $node->{rmon}{$portid} = sub { |
201 | $node->send (["", exit => $portid]); |
197 | $node->send (["", kil => $portid]); |
202 | }); |
198 | }); |
203 | }, |
199 | }, |
204 | exit => sub { |
200 | kil => sub { |
205 | my $cbs = delete $SRCNODE->{lmon}{$_[0]} |
201 | my $cbs = delete $SRCNODE->{lmon}{$_[0]} |
206 | or return; |
202 | or return; |
207 | |
203 | |
208 | $_->() for @$cbs; |
204 | $_->() for @$cbs; |
209 | }, |
205 | }, |