11 |
|
|
12 |
sock |
sock |
13 |
state |
state |
|
queue |
|
14 |
store |
store |
15 |
/ ); |
/ ); |
16 |
|
|
34 |
my $server = CWMP::Session->new({ |
my $server = CWMP::Session->new({ |
35 |
sock => $io_socket_object, |
sock => $io_socket_object, |
36 |
store => 'state.db', |
store => 'state.db', |
|
queue => [ |
|
|
'GetRPCMethods', |
|
|
[ 'GetParameterValyes', 'InternetGatewayDevice.DeviceInfo.SerialNumber', 0 ], |
|
|
], |
|
37 |
debug => 1, |
debug => 1, |
38 |
}); |
}); |
39 |
|
|
148 |
)."\r\n"); |
)."\r\n"); |
149 |
|
|
150 |
$sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} ); |
$sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} ); |
151 |
|
|
152 |
|
my $queue = CWMP::Queue->new({ |
153 |
|
id => $self->store->ID_to_uid( $state->{ID}, $state ), |
154 |
|
debug => $self->debug, |
155 |
|
}); |
156 |
|
my $job; |
157 |
$xml = ''; |
$xml = ''; |
158 |
|
|
159 |
if ( my $dispatch = $state->{_dispatch} ) { |
if ( my $dispatch = $state->{_dispatch} ) { |
160 |
$xml = $self->dispatch( $dispatch ); |
$xml = $self->dispatch( $dispatch ); |
161 |
} elsif ( $dispatch = shift @{ $self->queue } ) { |
} elsif ( $job = $queue->dequeue ) { |
162 |
$xml = $self->dispatch( $dispatch ); |
$xml = $self->dispatch( $job->dispatch ); |
163 |
} elsif ( $size == 0 ) { |
} elsif ( $size == 0 ) { |
164 |
warn ">>> no more queued commands, closing connection\n"; |
warn ">>> no more queued commands, closing connection\n"; |
165 |
return 0; |
return 0; |
174 |
|
|
175 |
warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes\n"; |
warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes\n"; |
176 |
|
|
177 |
|
$job->finish if $job; |
178 |
warn "### request over\n" if $self->debug; |
warn "### request over\n" if $self->debug; |
179 |
|
|
180 |
return 1; # next request |
return 1; # next request |