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 |
session |
11 |
background |
background |
12 |
debug |
debug |
13 |
|
|
30 |
|
|
31 |
my $server = CWMP::Server->new({ |
my $server = CWMP::Server->new({ |
32 |
port => 3333, |
port => 3333, |
33 |
store => { |
session => { ... }, |
|
module => 'DBMDeep', |
|
|
path => 'var/', |
|
|
}, |
|
34 |
background => 1, |
background => 1, |
35 |
debug => 1 |
debug => 1 |
36 |
}); |
}); |
43 |
|
|
44 |
port to listen on |
port to listen on |
45 |
|
|
46 |
=item store |
=item session |
47 |
|
|
48 |
hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep> |
hash with key C<module> with value C<DBMDeep> if L<CWMP::Store::DBMDeep> |
49 |
is used. Other parametars are optional. |
is used. Other parametars are optional. |
67 |
CWMP::Server::Helper->new({ |
CWMP::Server::Helper->new({ |
68 |
proto => 'tcp', |
proto => 'tcp', |
69 |
port => $self->port, |
port => $self->port, |
70 |
store => $self->store, |
session => $self->session, |
71 |
debug => $self->debug, |
debug => $self->debug, |
72 |
background => $self->background, |
background => $self->background, |
73 |
}) |
}) |
104 |
$self->SUPER::options($template); |
$self->SUPER::options($template); |
105 |
|
|
106 |
# new single-value options |
# new single-value options |
107 |
foreach my $p ( qw/ store debug / ) { |
foreach my $p ( qw/ session debug / ) { |
108 |
$prop->{ $p } ||= undef; |
$prop->{ $p } ||= undef; |
109 |
$template->{ $p } = \$prop->{ $p }; |
$template->{ $p } = \$prop->{ $p }; |
110 |
} |
} |
129 |
my $sock = $prop->{client}; |
my $sock = $prop->{client}; |
130 |
confess "no sock in ", ref( $self ) unless $sock; |
confess "no sock in ", ref( $self ) unless $sock; |
131 |
|
|
132 |
|
my $sess = $prop->{session} || confess "no session"; |
133 |
|
|
134 |
eval { |
eval { |
135 |
my $session = CWMP::Session->new({ |
$sess->{sock} = $sock; |
136 |
sock => $sock, |
$sess->{debug} = $prop->{debug}; |
137 |
store => $prop->{store}, |
|
138 |
debug => $prop->{debug}, |
warn "## sess = ", dump( $sess ); |
139 |
}) || confess "can't create session"; |
|
140 |
|
my $session = CWMP::Session->new( $sess ) || confess "can't create session from ",dump( $sess ); |
141 |
|
|
142 |
while ( $session->process_request ) { |
while ( $session->process_request ) { |
143 |
warn "...waiting for next request from CPE...\n"; |
warn "...waiting for next request from CPE...\n"; |
144 |
} |
} |
145 |
}; |
}; |
146 |
|
|
147 |
if ($@) { |
warn "ERROR: $@\n" if $@; |
|
warn $@; |
|
|
} |
|
148 |
|
|
149 |
warn "...returning to accepting new connections\n"; |
warn "...returning to accepting new connections\n"; |
150 |
|
|