got routing essentially working
[spider.git] / perl / DXProtout.pm
index 66252c7aac3f441dfa67813e2ee264cdc10bf5dc..0be5330df39df4d9c998ccd83d6f22accca923c0 100644 (file)
@@ -28,10 +28,10 @@ sub pc10
   my ($self, $to, $via, $text) = @_;
   my $user2 = $via ? $to : ' ';
   my $user1 = $via ? $via : $to;
-  my $mycall = $self->call;
+  my $from = $self->call();
   $text = unpad($text);
   $text = ' ' if !$text;
-  return "PC10^$mycall^$user1^$text^*^$user2^$main::mycall^~";  
+  return "PC10^$from^$user1^$text^*^$user2^$main::mycall^~";  
 }
 
 # create a dx message (called $self->pc11(...)
@@ -69,11 +69,11 @@ sub pc16
   my $self = shift;
   my @out;
 
-  while (@_) {
+  foreach (@_) {
     my $str = "PC16^$self->{call}";
     my $i;
     
-    for ($i = 0; @_ && $i < $DXProt::pc16_max_users; $i++) {
+    for ($i = 0; @_ > 0  && $i < $DXProt::pc16_max_users; $i++) {
       my $ref = shift;
          $str .= sprintf "^%s %s %d", $ref->call, $ref->confmode ? '*' : '-', $ref->here;
        }
@@ -86,9 +86,9 @@ sub pc16
 # remove a local user
 sub pc17
 {
-  my $self = shift;
+  my ($self, $ref) = @_;
   my $hops = get_hops(17);
-  return "PC17^$self->{call}^$main::mycall^$hops^";
+  return "PC17^$self->{call}^$ref->{call}^$hops^";
 }
 
 # Request init string
@@ -106,12 +106,14 @@ sub pc19
   my @out;
 
   while (@_) {
-    my $str = "PC19^$self->{call}";
+    my $str = "PC19";
     my $i;
     
     for ($i = 0; @_ && $i < $DXProt::pc19_max_nodes; $i++) {
       my $ref = shift;
-      $str .= "^$ref->{here}^$ref->{call}^$ref->{confmode}^$ref->{pcversion}";
+         my $here = $ref->{here} ? '1' : '0';
+         my $confmode = $ref->{confmode} ? '1' : '0';
+      $str .= "^$here^$ref->{call}^$confmode^$ref->{pcversion}";
        }
     $str .= sprintf "^%s^", get_hops(19);
        push @out, $str;
@@ -157,7 +159,8 @@ sub pc38
 # periodic update of users, plus keep link alive device (always H99)
 sub pc50
 {
-  my $n = DXNodeuser->count;
+  my $me = DXCluster->get($main::mycall);
+  my $n = $me->users ? $me->users : '0';
   return "PC50^$main::mycall^$n^H99^";
 }