/[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 199 by dpavlin, Wed Nov 14 18:16:14 2007 UTC revision 202 by dpavlin, Wed Nov 14 21:52:45 2007 UTC
# Line 7  use warnings; Line 7  use warnings;
7  use base qw/Class::Accessor/;  use base qw/Class::Accessor/;
8  __PACKAGE__->mk_accessors( qw/  __PACKAGE__->mk_accessors( qw/
9  debug  debug
10    create_dump
11  store  store
12    
13  sock  sock
# Line 35  CWMP::Session - implement logic of CWMP Line 36  CWMP::Session - implement logic of CWMP
36          sock => $io_socket_object,          sock => $io_socket_object,
37          store => 'state.db',          store => 'state.db',
38          debug => 1,          debug => 1,
39            create_dump => 1,
40    });    });
41    
42  =cut  =cut
# Line 59  sub new { Line 61  sub new {
61          # FIXME looks ugly. Should we have separate accessor for this?          # FIXME looks ugly. Should we have separate accessor for this?
62          $self->store( $store_obj );          $self->store( $store_obj );
63    
64            $self->create_dump( 1 ) if $self->debug > 2;
65    
66          return $self;          return $self;
67  }  }
68    
# Line 105  sub process_request { Line 109  sub process_request {
109          $dump_nr++;          $dump_nr++;
110          my $file = sprintf("dump/%04d-%s.request", $dump_nr, $sock->peerhost);          my $file = sprintf("dump/%04d-%s.request", $dump_nr, $sock->peerhost);
111    
112          if ( $self->debug > 2 ) {          if ( $self->create_dump ) {
113                  write_file( $file, $r->as_string );                  write_file( $file, $r->as_string );
114                  warn "### request dumped to file: $file\n";                  warn "### request dumped to file: $file\n";
115          }          }
# Line 120  sub process_request { Line 124  sub process_request {
124    
125                  $state = CWMP::Request->parse( $xml );                  $state = CWMP::Request->parse( $xml );
126    
127                  if ( defined( $state->{_dispatch} ) && $self->debug > 2 ) {                  if ( defined( $state->{_dispatch} ) && $self->create_dump ) {
128                          my $type = sprintf("dump/%04d-%s-%s", $dump_nr, $sock->peerhost, $state->{_dispatch});                          my $type = sprintf("dump/%04d-%s-%s", $dump_nr, $sock->peerhost, $state->{_dispatch});
129                          symlink $file, $type || warn "can't symlink $file -> $type: $!";                          symlink $file, $type || warn "can't symlink $file -> $type: $!";
130                  }                  }
131    
132                  warn "## acquired state = ", dump( $state ), "\n";                  warn "## acquired state = ", dump( $state ), "\n";
133    
134                    if ( ! defined( $state->{DeviceID} ) ) {
135                            warn "## state with DeviceID, using old one...\n";
136                            $state->{DeviceID} = $self->state->{DeviceID};
137                    }
138    
139                  $self->state( $state );                  $self->state( $state );
140                  $self->store->update_state( ID => $state->{ID}, $state );                  $self->store->update_state( ID => $state->{ID}, $state );
141    
# Line 204  warn "##!!! dispatch(",dump( @_ ),")\n"; Line 213  warn "##!!! dispatch(",dump( @_ ),")\n";
213                  warn ">>> dispatching to $dispatch with args ",dump( $args ),"\n";                  warn ">>> dispatching to $dispatch with args ",dump( $args ),"\n";
214                  my $xml = $response->$dispatch( $self->state, $args );                  my $xml = $response->$dispatch( $self->state, $args );
215                  warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug;                  warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
216                  if ( $self->debug > 2 ) {                  if ( $self->create_dump ) {
217                          my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);                          my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);
218                          write_file( $file, $xml );                          write_file( $file, $xml );
219                          warn "### response dump: $file\n";                          warn "### response dump: $file\n";

Legend:
Removed from v.199  
changed lines
  Added in v.202

  ViewVC Help
Powered by ViewVC 1.1.26