--- google/lib/CWMP/Server.pm 2007/06/22 20:00:48 86 +++ google/trunk/lib/CWMP/Server.pm 2007/11/18 17:03:09 210 @@ -7,8 +7,7 @@ use base qw/Class::Accessor/; __PACKAGE__->mk_accessors( qw/ port -store_path -default_queue +session background debug @@ -16,6 +15,7 @@ / ); use CWMP::Session; +use CWMP::Queue; use Carp qw/confess/; use Data::Dump qw/dump/; @@ -30,8 +30,7 @@ my $server = CWMP::Server->new({ port => 3333, - store_path => 'state.db', - default_queue => [ qw/GetRPCMethods GetParameterNames/ ], + session => { ... }, background => 1, debug => 1 }); @@ -44,13 +43,10 @@ port to listen on -=item store_path +=item session -path to L database file to preserve state - -=item default_queue - -commands which will be issued to every CPE on connect +hash with key C with value C if L +is used. Other parametars are optional. =back @@ -71,8 +67,7 @@ CWMP::Server::Helper->new({ proto => 'tcp', port => $self->port, - default_queue => $self->default_queue, - store_path => $self->store_path, + session => $self->session, debug => $self->debug, background => $self->background, }) @@ -109,16 +104,16 @@ $self->SUPER::options($template); # new single-value options - foreach my $p ( qw/ store_path debug / ) { + foreach my $p ( qw/ session debug / ) { $prop->{ $p } ||= undef; $template->{ $p } = \$prop->{ $p }; } # new multi-value options - foreach my $p ( qw/ default_queue / ) { - $prop->{ $p } ||= []; - $template->{ $p } = $prop->{ $p }; - } +# foreach my $p ( qw/ default_queue / ) { +# $prop->{ $p } ||= []; +# $template->{ $p } = $prop->{ $p }; +# } } @@ -134,20 +129,22 @@ my $sock = $prop->{client}; confess "no sock in ", ref( $self ) unless $sock; - warn "default CPE queue ( " . join(",",@{$prop->{default_queue}}) . " )" if defined($prop->{default_queue}); + my $sess = $prop->{session} || confess "no session"; - my $session = CWMP::Session->new({ - sock => $sock, - queue => $prop->{default_queue}, - store_path => $prop->{store_path}, - debug => $prop->{debug}, - }) || confess "can't create session"; + eval { + $sess->{sock} = $sock; + $sess->{debug} = $prop->{debug}; - while ( $session->process_request ) { - warn "...another one bites the dust...\n"; - } + my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess ); + + while ( $session->process_request ) { + warn "...waiting for next request from CPE...\n" if $prop->{debug}; + } + }; + + warn "ERROR: $@\n" if $@; - warn "...returning to accepting new connections\n"; + warn "...returning to accepting new connections\n" if $prop->{debug}; }