$sock->send( "Set-Cookie: ID=" . $state->{ID} . "; path=/\r\n" ) if ( $state->{ID} );
+ my $uid = $self->store->ID_to_uid( $state->{ID}, $state );
+
my $queue = CWMP::Queue->new({
- id => $self->store->ID_to_uid( $state->{ID}, $state ),
+ id => $uid,
debug => $self->debug,
});
my $job;
} elsif ( $job = $queue->dequeue ) {
$xml = $self->dispatch( $job->dispatch );
} elsif ( $size == 0 ) {
- warn ">>> no more queued commands, closing connection\n";
+ warn ">>> no more queued commands, closing connection to $uid\n";
return 0;
} else {
- warn ">>> empty response\n";
+ warn ">>> empty response to $uid\n";
$state->{NoMoreRequests} = 1;
$xml = $self->dispatch( 'xml', sub {} );
}
$sock->send( "Content-Length: " . length( $xml ) . "\r\n\r\n" );
$sock->send( $xml ) or die "can't send response";
- warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes\n";
+ warn ">>>> " . $sock->peerhost . " [" . localtime() . "] sent ", length( $xml )," bytes to $uid\n";
$job->finish if $job;
- warn "### request over\n" if $self->debug;
+ warn "### request over for $uid\n" if $self->debug;
return 1; # next request
};
sub dispatch {
my $self = shift;
- my $dispatch = shift || die "no dispatch?";
- my @args = @_;
+warn "##!!! dispatch(",dump( @_ ),")\n";
- if ( ref($dispatch) eq 'ARRAY' ) {
- my @a = @$dispatch;
- $dispatch = shift @a;
- push @args, @a;
- }
+ my $dispatch = shift || die "no dispatch?";
+ my $args = shift;
my $response = CWMP::Methods->new({ debug => $self->debug });
if ( $response->can( $dispatch ) ) {
- warn ">>> dispatching to $dispatch\n";
- my $xml = $response->$dispatch( $self->state, @args );
+ warn ">>> dispatching to $dispatch with args ",dump( $args ),"\n";
+ my $xml = $response->$dispatch( $self->state, $args );
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug;
if ( $self->debug > 2 ) {
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost);