/[cwmp]/google/trunk/lib/CWMP/Session.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /google/trunk/lib/CWMP/Session.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 49 by dpavlin, Tue Jun 19 20:46:51 2007 UTC revision 50 by dpavlin, Tue Jun 19 21:29:04 2007 UTC
# Line 10  debug Line 10  debug
10  port  port
11  sock  sock
12  state  state
13    queue
14  / );  / );
15    
16  use IO::Socket::INET;  use IO::Socket::INET;
# Line 170  sub process_request { Line 171  sub process_request {
171                  warn "last request state = ", dump( $state ), "\n";                  warn "last request state = ", dump( $state ), "\n";
172          }          }
173    
         my $response = CWMP::Response->new({ debug => $self->debug });  
174    
175          $sock->send(join("\r\n",          $sock->send(join("\r\n",
176                  'HTTP/1.1 200 OK',                  'HTTP/1.1 200 OK',
# Line 184  sub process_request { Line 184  sub process_request {
184          my $xml = '';          my $xml = '';
185    
186          if ( my $dispatch = $state->{_dispatch} ) {          if ( my $dispatch = $state->{_dispatch} ) {
187                  if ( $response->can( $dispatch ) ) {                  $xml = $self->dispatch( $dispatch );
188                          warn ">>> dispatching to $dispatch\n";          } elsif ( $dispatch = shift @{ $self->queue } ) {
189                          $xml = $response->$dispatch( $state ) . "\r\n";                  $xml = $self->dispatch( $dispatch );
190                          warn "## response payload: ",length($xml)," bytes\n$xml\n";          } elsif ( $size == 0 ) {
191                  } else {                  warn ">>> closing connection\n";
192                          confess "can't dispatch to $dispatch";                  return 0;
                 }  
193          } else {          } else {
194                  warn ">>> empty response\n";                  warn ">>> empty response\n";
195                    $state->{NoMoreRequests} = 1;
196                    $xml = $self->dispatch( 'xml', sub {} );
197          }          }
198    
199          $sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" );          $sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" );
# Line 202  sub process_request { Line 203  sub process_request {
203    
204  };  };
205    
206    =head2 dispatch
207    
208      $xml = $self->dispatch('Inform', $response_arguments );
209    
210    =cut
211    
212    sub dispatch {
213            my $self = shift;
214    
215            my $dispatch = shift || die "no dispatch?";
216    
217            my $response = CWMP::Response->new({ debug => $self->debug });
218    
219            if ( $response->can( $dispatch ) ) {
220                    warn ">>> dispatching to $dispatch\n";
221                    my $xml = $response->$dispatch( $self->state, @_ ) . "\r\n";
222                    warn "## response payload: ",length($xml)," bytes\n$xml\n";
223                    return $xml;
224            } else {
225                    confess "can't dispatch to $dispatch";
226            }
227    };
228    
229  =head2 read_headers  =head2 read_headers
230    
231  parse headers from request  parse headers from request

Legend:
Removed from v.49  
changed lines
  Added in v.50

  ViewVC Help
Powered by ViewVC 1.1.26