+ my $d = (gmtime($main::systime))[3];
+ if ($d != $dayno) {
+ $dayno = $d;
+ $daystart = $main::systime - ($main::systime % 86400);
+ }
+ if ($main::systime >= $lastmin + 60) {
+ per_minute();
+ $lastmin = $main::systime;
+ }
+}
+
+sub per_minute
+{
+ # send hello and cf packages periodically
+ foreach my $dxchan (DXChannel::get_all()) {
+ next if $dxchan->is_aranea;
+ if ($main::systime >= $dxchan->lasthello + $hello_interval) {
+ my $thing = Thingy::Hello->new(h => $dxchan->here);
+ $thing->{user} = $dxchan->{call} unless $dxchan == $main::me;
+ if (my $v = $dxchan->{version}) {
+ if ($dxchan->is_spider) {
+ $thing->{sw} = 'DXSp';
+ }
+ $thing->{v} = $v;
+ }
+ $thing->{b} = $dxchan->{build} if $dxchan->{build};
+ $thing->broadcast($dxchan);
+ $dxchan->lasthello($main::systime);
+ }
+ if ($dxchan->is_node) {
+ if ($main::systime >= $dxchan->lastcf + $cf_interval) {
+ my $call = $dxchan->call;
+ if ($dxchan == $main::me) {
+
+ # i am special but, currently, still a node
+ my $thing = Thingy::Rt->new_cf;
+ $thing->broadcast;
+ $dxchan->lastcf($main::systime);
+ } else {
+
+ # i am a pc protocol node connected directly
+ my $thing = Thingy::Rt->new();
+ $thing->{user} = $call unless $dxchan == $main::me;
+ if (my $nref = Route::Node::get($call)) {
+ $thing->copy_pc16_data($nref);
+ $thing->broadcast($dxchan);
+ $dxchan->lastcf($main::systime);
+ } else {
+ dbg("Aranea::per_minute: Route::Node for $call disappeared");
+ $dxchan->disconnect;
+ }
+ }
+ }
+ }
+ }
+}
+
+sub disconnect
+{
+ my $self = shift;
+ my $call = $self->call;
+
+ return if $self->{disconnecting}++;
+
+ my $thing = Thingy::Bye->new(origin=>$main::mycall, user=>$call);
+ $thing->broadcast($self);
+
+ # get rid of any PC16/17/19
+ DXProt::eph_del_regex("^PC1[679]*$call");
+
+ # do routing stuff, remove me from routing table
+ my $node = Route::Node::get($call);
+ my @rout;
+ if ($node) {
+ @rout = $node->del($main::routeroot);
+
+ # and all my ephemera as well
+ for (@rout) {
+ my $c = $_->call;
+ DXProt::eph_del_regex("^PC1[679].*$c");
+ }
+ }
+
+ RouteDB::delete_interface($call);
+
+ # unbusy and stop and outgoing mail
+ my $mref = DXMsg::get_busy($call);
+ $mref->stop_msg($call) if $mref;
+
+ # broadcast to all other nodes that all the nodes connected to via me are gone
+ DXProt::route_pc21($self, $main::mycall, undef, @rout) if @rout;
+
+ # remove outstanding pings
+ Thingy::Ping::forget($call);
+
+ # I was the last node visited
+ $self->user->node($main::mycall);
+
+ # send info to all logged in thingies
+ $self->tell_login('logoutn');
+
+ Log('Aranea', $call . " Disconnected");
+
+ $self->SUPER::disconnect;