/[cwmp]/google/trunk/lib/CWMP/Server.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/Server.pm

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

google/lib/CWMP/Server.pm revision 101 by dpavlin, Sun Jun 24 18:32:58 2007 UTC google/trunk/lib/CWMP/Server.pm revision 210 by dpavlin, Sun Nov 18 17:03:09 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  port  port
10  store_path  session
 default_queue  
11  background  background
12  debug  debug
13    
# Line 16  server Line 15  server
15  / );  / );
16    
17  use CWMP::Session;  use CWMP::Session;
18    use CWMP::Queue;
19    
20  use Carp qw/confess/;  use Carp qw/confess/;
21  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
# Line 30  CWMP::Server - description Line 30  CWMP::Server - description
30    
31    my $server = CWMP::Server->new({    my $server = CWMP::Server->new({
32          port => 3333,          port => 3333,
33          store_path => 'state.db',          session => { ... },
         default_queue => [ qw/GetRPCMethods GetParameterNames/ ],                                                            
34          background => 1,          background => 1,
35          debug => 1          debug => 1
36    });    });
# Line 44  Options: Line 43  Options:
43    
44  port to listen on  port to listen on
45    
46  =item store_path  =item session
47    
48  path to L<DBM::Deep> database file to preserve state  hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep>
49    is used. Other parametars are optional.
 =item default_queue  
   
 commands which will be issued to every CPE on connect  
50    
51  =back  =back
52    
# Line 71  sub new { Line 67  sub new {
67                  CWMP::Server::Helper->new({                  CWMP::Server::Helper->new({
68                          proto => 'tcp',                          proto => 'tcp',
69                          port => $self->port,                          port => $self->port,
70                          default_queue => $self->default_queue,                          session => $self->session,
                         store_path => $self->store_path,  
71                          debug => $self->debug,                          debug => $self->debug,
72                          background => $self->background,                          background => $self->background,
73                  })                  })
# Line 109  sub options { Line 104  sub options {
104          $self->SUPER::options($template);          $self->SUPER::options($template);
105    
106          # new single-value options          # new single-value options
107          foreach my $p ( qw/ store_path debug / ) {          foreach my $p ( qw/ session debug / ) {
108                  $prop->{ $p } ||= undef;                  $prop->{ $p } ||= undef;
109                  $template->{ $p } = \$prop->{ $p };                  $template->{ $p } = \$prop->{ $p };
110          }          }
111    
112          # new multi-value options          # new multi-value options
113          foreach my $p ( qw/ default_queue / ) {  #       foreach my $p ( qw/ default_queue / ) {
114                  $prop->{ $p } ||= [];  #               $prop->{ $p } ||= [];
115                  $template->{ $p } = $prop->{ $p };  #               $template->{ $p } = $prop->{ $p };
116          }  #       }
117  }  }
118    
119    
# Line 134  sub process_request { Line 129  sub process_request {
129          my $sock = $prop->{client};          my $sock = $prop->{client};
130          confess "no sock in ", ref( $self ) unless $sock;          confess "no sock in ", ref( $self ) unless $sock;
131    
132          warn "default CPE queue ( " . join(",",@{$prop->{default_queue}}) . " )\n" if defined($prop->{default_queue});          my $sess = $prop->{session} || confess "no session";
133    
134          my $session = CWMP::Session->new({          eval  {
135                  sock => $sock,                  $sess->{sock} = $sock;
136                  queue => $prop->{default_queue},                  $sess->{debug} = $prop->{debug};
                 store_path => $prop->{store_path},  
                 debug => $prop->{debug},  
         }) || confess "can't create session";  
137    
138          while ( $session->process_request ) {                  my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess );
139                  warn "...another one bites the dust...\n";  
140          }                  while ( $session->process_request ) {
141                            warn "...waiting for next request from CPE...\n" if $prop->{debug};
142                    }
143            };
144    
145            warn "ERROR: $@\n" if $@;
146    
147          warn "...returning to accepting new connections\n";          warn "...returning to accepting new connections\n" if $prop->{debug};
148    
149  }  }
150    

Legend:
Removed from v.101  
changed lines
  Added in v.210

  ViewVC Help
Powered by ViewVC 1.1.26