chopping up dup messages in Client::process()
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Aug 2006 00:35:12 +0000 (00:35 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 30 Aug 2006 00:35:12 +0000 (00:35 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@5764 dcc99617-32d9-48b4-a31d-7c20da2025e4

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

index b90e172..d67e77d 100644 (file)
@@ -192,6 +192,7 @@ sub timed_read {
                $self->{temp_buffer} = '';
 
                my ($tag) = ($buffer =~ /<([^\s\?\>]+)/o);
+               $self->{last_tag} = $tag;
                $logger->transport("Using tag: $tag  ", INTERNAL);
 
                if ( $buffer =~ /^(.*?<\/$tag>){1}(.*)/s) {
@@ -285,7 +286,8 @@ sub timed_read {
 
                                if ($first_read) {
                                        $logger->transport(" First read Buffer\n [$buffer]", INTERNAL);
-                                       ($tag) = ($buffer =~ /<([^\s\?\>]+){1}/o);
+                                       ($tag) = ($buffer =~ /<([^\s\?\>\/]+){1}/o);
+                                       $self->{last_tag} = $tag;
                                        $first_read--;
                                        $logger->transport("Using tag: $tag  ", INTERNAL);
                                }
@@ -563,6 +565,18 @@ sub process {
                        "Call to Client->timed_read( $timeout ) successfully returned data", INTERNAL );
        }
 
+       my $t = $self->{last_tag};
+       my @msgs = $val =~ /(<$t[^>]*>.*?<\/$t>)/g;
+       $val = shift(@msgs);
+
+       if (@msgs) {
+               my $tmp = $self->{temp_buffer};
+
+               $self->{temp_buffer} = '';
+               $self->{temp_buffer} .= $_ for (@msgs);
+               $self->{temp_buffer} .= $tmp;
+       }
+
        return $val;
 
 }