1 # Dobrica Pavlinusic, <dpavlin@rot13.org> 06/22/07 14:35:38 CEST
7 use base qw/Class::Accessor/;
8 __PACKAGE__->mk_accessors( qw/
22 use Data::Dump qw/dump/;
26 CWMP::Server - description
32 my $server = CWMP::Server->new({
49 hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep>
50 is used. Other parametars are optional.
58 my $self = $class->SUPER::new( @_ );
60 warn "created ", __PACKAGE__, "(", dump( @_ ), ") object\n" if $self->debug;
62 warn "ACS waiting for request on port ", $self->port, "\n";
64 $self->debug( 0 ) unless $self->debug;
65 warn "## debug level: ", $self->debug, "\n" if $self->debug;
68 CWMP::Server::Helper->new({
71 session => $self->session,
72 debug => $self->debug,
73 background => $self->background,
90 package CWMP::Server::Helper;
95 use base qw/Net::Server/;
97 use Data::Dump qw/dump/;
101 my $prop = $self->{'server'};
102 my $template = shift;
104 ### setup options in the parent classes
105 $self->SUPER::options($template);
107 # new single-value options
108 foreach my $p ( qw/ session debug / ) {
109 $prop->{ $p } ||= undef;
110 $template->{ $p } = \$prop->{ $p };
113 # new multi-value options
114 # foreach my $p ( qw/ default_queue / ) {
115 # $prop->{ $p } ||= [];
116 # $template->{ $p } = $prop->{ $p };
121 =head2 process_request
125 sub process_request {
128 my $leak = CWMP::MemLeak->new;
130 my $prop = $self->{server};
131 confess "no server in ", ref( $self ) unless $prop;
132 my $sock = $prop->{client};
133 confess "no sock in ", ref( $self ) unless $sock;
135 my $sess = $prop->{session} || confess "no session";
138 $sess->{sock} = $sock;
139 $sess->{debug} = $prop->{debug};
141 my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess );
143 while ( $session->process_request ) {
144 warn "...waiting for next request from CPE...\n" if $prop->{debug};
148 warn "ERROR: $@\n" if $@;
150 warn "...returning to accepting new connections\n" if $prop->{debug};