7 |
use base qw/Class::Accessor/; |
use base qw/Class::Accessor/; |
8 |
__PACKAGE__->mk_accessors( qw/ |
__PACKAGE__->mk_accessors( qw/ |
9 |
port |
port |
10 |
store_path |
store |
11 |
default_queue |
default_queue |
12 |
background |
background |
13 |
debug |
debug |
30 |
|
|
31 |
my $server = CWMP::Server->new({ |
my $server = CWMP::Server->new({ |
32 |
port => 3333, |
port => 3333, |
33 |
store_path => 'state.db', |
store => { |
34 |
|
module => 'DBMDeep', |
35 |
|
path => 'var/', |
36 |
|
}, |
37 |
default_queue => [ qw/GetRPCMethods GetParameterNames/ ], |
default_queue => [ qw/GetRPCMethods GetParameterNames/ ], |
38 |
background => 1, |
background => 1, |
39 |
debug => 1 |
debug => 1 |
47 |
|
|
48 |
port to listen on |
port to listen on |
49 |
|
|
50 |
=item store_path |
=item store |
51 |
|
|
52 |
path to L<DBM::Deep> database file to preserve state |
hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep> |
53 |
|
is used. Other parametars are optional. |
54 |
|
|
55 |
=item default_queue |
=item default_queue |
56 |
|
|
76 |
proto => 'tcp', |
proto => 'tcp', |
77 |
port => $self->port, |
port => $self->port, |
78 |
default_queue => $self->default_queue, |
default_queue => $self->default_queue, |
79 |
store_path => $self->store_path, |
store => $self->store, |
80 |
debug => $self->debug, |
debug => $self->debug, |
81 |
background => $self->background, |
background => $self->background, |
82 |
}) |
}) |
113 |
$self->SUPER::options($template); |
$self->SUPER::options($template); |
114 |
|
|
115 |
# new single-value options |
# new single-value options |
116 |
foreach my $p ( qw/ store_path debug / ) { |
foreach my $p ( qw/ store debug / ) { |
117 |
$prop->{ $p } ||= undef; |
$prop->{ $p } ||= undef; |
118 |
$template->{ $p } = \$prop->{ $p }; |
$template->{ $p } = \$prop->{ $p }; |
119 |
} |
} |
138 |
my $sock = $prop->{client}; |
my $sock = $prop->{client}; |
139 |
confess "no sock in ", ref( $self ) unless $sock; |
confess "no sock in ", ref( $self ) unless $sock; |
140 |
|
|
141 |
warn "default CPE queue ( " . join(",",@{$prop->{default_queue}}) . " )\n" if defined($prop->{default_queue}); |
warn "default CPE queue ", dump( $prop->{default_queue} ), "\n" if defined($prop->{default_queue}); |
142 |
|
|
143 |
my $session = CWMP::Session->new({ |
eval { |
144 |
sock => $sock, |
my $session = CWMP::Session->new({ |
145 |
queue => $prop->{default_queue}, |
sock => $sock, |
146 |
store_path => $prop->{store_path}, |
queue => $prop->{default_queue}, |
147 |
debug => $prop->{debug}, |
store => $prop->{store}, |
148 |
}) || confess "can't create session"; |
debug => $prop->{debug}, |
149 |
|
}) || confess "can't create session"; |
150 |
|
|
151 |
|
while ( $session->process_request ) { |
152 |
|
warn "...another one bites the dust...\n"; |
153 |
|
} |
154 |
|
}; |
155 |
|
|
156 |
while ( $session->process_request ) { |
if ($@) { |
157 |
warn "...another one bites the dust...\n"; |
warn $@; |
158 |
} |
} |
159 |
|
|
160 |
warn "...returning to accepting new connections\n"; |
warn "...returning to accepting new connections\n"; |