193 |
sub dispatch { |
sub dispatch { |
194 |
my $self = shift; |
my $self = shift; |
195 |
|
|
196 |
my $dispatch = shift || die "no dispatch?"; |
warn "##!!! dispatch(",dump( @_ ),")\n"; |
|
my @args = @_; |
|
197 |
|
|
198 |
if ( ref($dispatch) eq 'ARRAY' ) { |
my $dispatch = shift || die "no dispatch?"; |
199 |
my @a = @$dispatch; |
my $args = shift; |
|
$dispatch = shift @a; |
|
|
push @args, @a; |
|
|
} |
|
200 |
|
|
201 |
my $response = CWMP::Methods->new({ debug => $self->debug }); |
my $response = CWMP::Methods->new({ debug => $self->debug }); |
202 |
|
|
203 |
if ( $response->can( $dispatch ) ) { |
if ( $response->can( $dispatch ) ) { |
204 |
warn ">>> dispatching to $dispatch\n"; |
warn ">>> dispatching to $dispatch with args ",dump( $args ),"\n"; |
205 |
my $xml = $response->$dispatch( $self->state, @args ); |
my $xml = $response->$dispatch( $self->state, $args ); |
206 |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
warn "## response payload: ",length($xml)," bytes\n$xml\n" if $self->debug; |
207 |
if ( $self->debug > 2 ) { |
if ( $self->debug > 2 ) { |
208 |
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost); |
my $file = sprintf("dump/%04d-%s.response", $dump_nr++, $self->sock->peerhost); |