+sub chgstate
+{
+ my $self = shift;
+ my $state = shift;
+ dbg("Investigate: $self->{call} via $self->{via} state $self->{state}->$state") if isdbg('investigate');
+ $self->{state} = $state;
+}
+
+sub handle_ping
+{
+ my $self = shift;
+ dbg("Investigate: ping received for $self->{call} via $self->{via}") if isdbg('investigate');
+ if ($self->{state} eq 'waitping') {
+ delete $list{"$self->{via},$self->{call}"};
+ my $user = DXUser->get_current($self->{via});
+ if ($user) {
+ $user->set_believe($self->{call});
+ $user->put;
+ }
+ my $dxchan = DXChannel->get($self->{via});
+ if ($dxchan) {
+ dbg("Investigate: sending PC19 for $self->{call}") if isdbg('investigate');
+ foreach my $pc (@{$self->{pcxx}}) {
+ no strict 'refs';
+ my $handle = "handle_$pc->[0]";
+ dbg("Investigate: sending PC$pc->[0] (" . join(',', @$pc) . ")") if isdbg('investigate');
+ $pc->[1] =~ s/\^/\\\^/g;
+ DXProt::eph_del_regex($pc->[1]);
+ $dxchan->$handle(@$pc);
+ }
+ }
+ }
+}
+
+sub store_pcxx
+{
+ my $self = shift;
+ dbg("Investigate: Storing (". join(',', @_) . ")") if isdbg('investigate');
+ push @{$self->{pcxx}}, [@_];
+}
+
+sub process
+{
+ while (my ($k, $v) = each %list) {
+ if ($v->{state} eq 'start') {
+ if ($main::systime > $lastping+$pingint) {
+ DXProt::addping($main::mycall, $v->{call}, $v->{via});
+ $v->{start} = $lastping = $main::systime;
+ dbg("Investigate: ping sent to $v->{call} via $v->{via}") if isdbg('investigate');
+ $v->chgstate('waitping');
+ }
+ } elsif ($v->{state} eq 'waitping') {
+ if ($main::systime > $v->{start} + $maxpingwait) {
+ dbg("Investigate: ping timed out on $v->{call} via $v->{via}") if isdbg('investigate');
+ delete $list{$k};
+ my $user = DXUser->get_current($v->{via});
+ if ($user) {
+ $user->lastping($main::systime);
+ $user->put;
+ }
+ }
+ }
+ }
+}
+
+