1 # Dobrica Pavlinusic, <dpavlin@rot13.org> 06/22/07 14:35:38 CEST
7 use base qw/Class::Accessor/;
8 __PACKAGE__->mk_accessors( qw/
21 use Data::Dump qw/dump/;
25 CWMP::Server - description
31 my $server = CWMP::Server->new({
48 hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep>
49 is used. Other parametars are optional.
57 my $self = $class->SUPER::new( @_ );
59 warn "created ", __PACKAGE__, "(", dump( @_ ), ") object\n" if $self->debug;
61 warn "ACS waiting for request on port ", $self->port, "\n";
63 $self->debug( 0 ) unless $self->debug;
64 warn "## debug level: ", $self->debug, "\n" if $self->debug;
67 CWMP::Server::Helper->new({
70 session => $self->session,
71 debug => $self->debug,
72 background => $self->background,
89 package CWMP::Server::Helper;
94 use base qw/Net::Server/;
96 use Data::Dump qw/dump/;
100 my $prop = $self->{'server'};
101 my $template = shift;
103 ### setup options in the parent classes
104 $self->SUPER::options($template);
106 # new single-value options
107 foreach my $p ( qw/ session debug / ) {
108 $prop->{ $p } ||= undef;
109 $template->{ $p } = \$prop->{ $p };
112 # new multi-value options
113 # foreach my $p ( qw/ default_queue / ) {
114 # $prop->{ $p } ||= [];
115 # $template->{ $p } = $prop->{ $p };
120 =head2 process_request
124 sub process_request {
127 my $prop = $self->{server};
128 confess "no server in ", ref( $self ) unless $prop;
129 my $sock = $prop->{client};
130 confess "no sock in ", ref( $self ) unless $sock;
132 my $sess = $prop->{session} || confess "no session";
135 $sess->{sock} = $sock;
136 $sess->{debug} = $prop->{debug};
138 my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess );
140 while ( $session->process_request ) {
141 warn "...waiting for next request from CPE...\n" if $prop->{debug};
145 warn "ERROR: $@\n" if $@;
147 warn "...returning to accepting new connections\n" if $prop->{debug};