X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=lib%2FCWMP%2FServer.pm;h=13a923c8efcbeeda5dacb6770c2dc050f7979704;hb=0096fa526f2bff8da10e3c81d14daa03efc6aef2;hp=e90fa1340beb8f7ed4f6f28f6954a8fad65680d6;hpb=fec1acf5d1dfce1a661535d2b40b0e9d97de6005;p=perl-cwmp.git diff --git a/lib/CWMP/Server.pm b/lib/CWMP/Server.pm index e90fa13..13a923c 100644 --- a/lib/CWMP/Server.pm +++ b/lib/CWMP/Server.pm @@ -7,7 +7,7 @@ use warnings; use base qw/Class::Accessor/; __PACKAGE__->mk_accessors( qw/ port -store +session background debug @@ -30,10 +30,7 @@ CWMP::Server - description my $server = CWMP::Server->new({ port => 3333, - store => { - module => 'DBMDeep', - path => 'var/', - }, + session => { ... }, background => 1, debug => 1 }); @@ -46,7 +43,7 @@ Options: port to listen on -=item store +=item session hash with key C with value C if L is used. Other parametars are optional. @@ -70,7 +67,7 @@ sub new { CWMP::Server::Helper->new({ proto => 'tcp', port => $self->port, - store => $self->store, + session => $self->session, debug => $self->debug, background => $self->background, }) @@ -107,7 +104,7 @@ sub options { $self->SUPER::options($template); # new single-value options - foreach my $p ( qw/ store debug / ) { + foreach my $p ( qw/ session debug / ) { $prop->{ $p } ||= undef; $template->{ $p } = \$prop->{ $p }; } @@ -132,23 +129,22 @@ sub process_request { my $sock = $prop->{client}; confess "no sock in ", ref( $self ) unless $sock; + my $sess = $prop->{session} || confess "no session"; + eval { - my $session = CWMP::Session->new({ - sock => $sock, - store => $prop->{store}, - debug => $prop->{debug}, - }) || confess "can't create session"; + $sess->{sock} = $sock; + $sess->{debug} = $prop->{debug}; + + 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"; + warn "...waiting for next request from CPE...\n" if $prop->{debug}; } }; - if ($@) { - warn $@; - } + warn "ERROR: $@\n" if $@; - warn "...returning to accepting new connections\n"; + warn "...returning to accepting new connections\n" if $prop->{debug}; }