projects
/
perl-cwmp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r230@brr: dpavlin | 2007-11-18 17:42:53 +0100
[perl-cwmp.git]
/
lib
/
CWMP
/
Server.pm
diff --git
a/lib/CWMP/Server.pm
b/lib/CWMP/Server.pm
index
0a67293
..
5a452c2
100644
(file)
--- a/
lib/CWMP/Server.pm
+++ b/
lib/CWMP/Server.pm
@@
-7,8
+7,7
@@
use warnings;
use base qw/Class::Accessor/;
__PACKAGE__->mk_accessors( qw/
port
use base qw/Class::Accessor/;
__PACKAGE__->mk_accessors( qw/
port
-store_path
-default_queue
+session
background
debug
background
debug
@@
-16,6
+15,7
@@
server
/ );
use CWMP::Session;
/ );
use CWMP::Session;
+use CWMP::Queue;
use Carp qw/confess/;
use Data::Dump qw/dump/;
use Carp qw/confess/;
use Data::Dump qw/dump/;
@@
-30,8
+30,7
@@
CWMP::Server - description
my $server = CWMP::Server->new({
port => 3333,
my $server = CWMP::Server->new({
port => 3333,
- store_path => 'state.db',
- default_queue => [ qw/GetRPCMethods GetParameterNames/ ],
+ session => { ... },
background => 1,
debug => 1
});
background => 1,
debug => 1
});
@@
-44,13
+43,10
@@
Options:
port to listen on
port to listen on
-=item s
tore_path
+=item s
ession
-path to L<DBM::Deep> database file to preserve state
-
-=item default_queue
-
-commands which will be issued to every CPE on connect
+hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep>
+is used. Other parametars are optional.
=back
=back
@@
-71,8
+67,7
@@
sub new {
CWMP::Server::Helper->new({
proto => 'tcp',
port => $self->port,
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,
})
debug => $self->debug,
background => $self->background,
})
@@
-109,16
+104,16
@@
sub options {
$self->SUPER::options($template);
# new single-value options
$self->SUPER::options($template);
# new single-value options
- foreach my $p ( qw/ s
tore_path
debug / ) {
+ foreach my $p ( qw/ s
ession
debug / ) {
$prop->{ $p } ||= undef;
$template->{ $p } = \$prop->{ $p };
}
# new multi-value options
$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,18
+129,20
@@
sub process_request {
my $sock = $prop->{client};
confess "no sock in ", ref( $self ) unless $sock;
my $sock = $prop->{client};
confess "no sock in ", ref( $self ) unless $sock;
-
warn "default CPE queue ( " . join(",",@{$prop->{default_queue}}) . " )\n" 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";
+ }
+ };
+
+ warn "ERROR: $@\n" if $@;
warn "...returning to accepting new connections\n";
warn "...returning to accepting new connections\n";