added router 'unregister' loop to DESTROY
authorerickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 3 Mar 2005 18:56:57 +0000 (18:56 +0000)
committererickson <erickson@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 3 Mar 2005 18:56:57 +0000 (18:56 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@167 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Transport/SlimJabber/Inbound.pm

index 13a9a7f..247326a 100644 (file)
@@ -64,6 +64,29 @@ This service should be loaded at system startup.
        }
 
 }
+
+sub DESTROY {
+       my $self = shift;
+
+       my $routers = $self->{routers}; #store for destroy
+       my $router_name = $self->{router_name};
+
+       unless($router_name and $routers) {
+               return;
+       }
+
+       my @targets;
+       for my $router (@$routers) {
+               push @targets, "$router_name\@$router/router";
+       }
+
+       for my $router (@targets) {
+               if($self->tcp_connected()) {
+                       $self->send( to => $router, body => "registering", 
+                               router_command => "unregister" , router_class => $self->{app} );
+               }
+       }
+}
        
 sub listen {
        my $self = shift;
@@ -75,6 +98,9 @@ sub listen {
                my $conf = OpenSRF::Utils::Config->current;
                my $router_name = $conf->bootstrap->router_name;
                my $routers = $conf->bootstrap->domains;
+
+               $self->{routers} = $routers; #store for destroy
+               $self->{router_name} = $router_name;
        
                unless($router_name and $routers) {
                        throw OpenSRF::EX::Config