added announce
[spider.git] / perl / DXCommandmode.pm
index 9f7b3885712d7366a1daa66d4f272985502d528f..ddfefc6e082af843a86e5e14e188400bb761ab43 100644 (file)
@@ -59,7 +59,16 @@ sub start
   # set some necessary flags on the user if they are connecting
   $self->{wwv} = $self->{talk} = $self->{ann} = $self->{here} = $self->{dx} = 1;
   $self->prompt() if $self->{state} =~ /^prompt/o;
-
+  
+  # add yourself to the database
+  my $node = DXNode->get($main::mycall) or die "$main::mycall not allocated in DXNode database";
+  my $cuser = DXNodeuser->new($self, $node, $call, 0, 1);
+  $node->dxchan($self) if $call eq $main::myalias;       # send all output for mycall to myalias
+  
+  # issue a pc16 to everybody interested
+  my $nchan = DXChannel->get($main::mycall);
+  my @pc16 = DXProt::pc16($nchan, $cuser);
+  DXProt::broadcast_ak1a(@pc16);
 }
 
 #
@@ -133,7 +142,21 @@ sub process
 #
 sub finish
 {
+  my $self = shift;
+  my $call = $self->call;
 
+  if ($call eq $main::myalias) {   # unset the channel if it is us really
+    my $node = DXNode->get($main::mycall);
+       $node->{dxchan} = 0;
+  }
+  my $ref = DXNodeuser->get($call);
+
+  # issue a pc17 to everybody interested
+  my $nchan = DXChannel->get($main::mycall);
+  my $pc17 = $nchan->pc17($self);
+  DXProt::broadcast_ak1a($pc17);
+  
+  $ref->del() if $ref;
 }
 
 #
@@ -319,7 +342,7 @@ sub eval_file {
        }
        if ($@) {
          delete_package($package);
-         return (0, "Syserr: Eval err $@ on $package");
+         return (1, "Syserr: Eval err $@ on $package");
        }
                
        #cache it unless we're cleaning out each time
@@ -329,10 +352,10 @@ sub eval_file {
   my @r;
   my $c = qq{ \@r = \$self->$package(\@_); };
   dbg('eval', "cluster cmd = $c\n");
-  eval  $c; ;
+  eval  $c;
   if ($@) {
     delete_package($package);
-       return (0, "Syserr: Eval err $@ on cached $package");
+       return (1, "Syserr: Eval err $@ on cached $package");
   }
 
   #take a look if you want