adding full_request (not sure if we need this) and fixing thinko on disconnect
authormiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 29 Mar 2005 21:12:26 +0000 (21:12 +0000)
committermiker <miker@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 29 Mar 2005 21:12:26 +0000 (21:12 +0000)
git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@251 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/AppSession.pm

index 1b6b557..0aafffd 100644 (file)
@@ -381,11 +381,7 @@ sub kill_me {
 
 sub disconnect {
        my $self = shift;
-       return unless $self;
-       unless( $self->state == DISCONNECTED ) {
-               $self->send('DISCONNECT', "") if ($self->endpoint == CLIENT);;
-               $self->state( DISCONNECTED ); 
-       }
+
        # run each 'disconnect' callback;
        if (exists $self->{callbacks}{disconnect}) {
                for my $sub (values %{$self->{callbacks}{disconnect}}) {
@@ -393,6 +389,11 @@ sub disconnect {
                }
        }
 
+       unless( $self->state == DISCONNECTED ) {
+               $self->send('DISCONNECT', "") if ($self->endpoint == CLIENT);;
+               $self->state( DISCONNECTED ); 
+       }
+
        $self->reset;
 }
 
@@ -413,6 +414,21 @@ sub request {
        $self->send('REQUEST',$method);
 }
 
+sub full_request {
+       my $self = shift;
+       my $meth = shift;
+
+       my $method;
+       if (!ref $meth) {
+               $method = new OpenSRF::DomainObject::oilsMethod ( method => $meth );
+       } else {
+               $method = $meth;
+       }
+       
+       $method->params( @_ );
+
+       $self->send(CONNECT => '', REQUEST => $method, DISCONNECT => '');
+}
 
 sub send {
        my $self = shift;
@@ -445,7 +461,7 @@ sub send {
 
                if ($msg_type eq 'DISCONNECT' ) {
                        $disconnect++;
-                       if( $self->state == DISCONNECTED) {
+                       if( $self->state == DISCONNECTED && !$connecting) {
                                next;
                        }
                }
@@ -503,7 +519,6 @@ sub send {
                        }
                }
        } 
-
        $logger->debug( "AppSession sending doc: " . $doc->toString(), INTERNAL );
 
 
@@ -512,6 +527,10 @@ sub send {
                                   thread => $self->session_id,
                                   body   => $doc->toString );
 
+       if( $disconnect) {
+               $self->state( DISCONNECTED );
+       }
+
        return $self->app_request( $tT );
 }