From 1431100b4737a61b1a294bbf66f9a5867dec358b Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 1 Nov 2016 17:03:03 -0400 Subject: [PATCH] LP#1631522: include example of ->dispatch in example app This patch also makes the Perl opensrf.math demo app work correctly, as it hadn't been constructing opensrf.dbmath method names correctly. Signed-off-by: Galen Charlton --- src/perl/lib/OpenSRF/Application/Demo/Math.pm | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/perl/lib/OpenSRF/Application/Demo/Math.pm b/src/perl/lib/OpenSRF/Application/Demo/Math.pm index 7f41456..9e53dcb 100644 --- a/src/perl/lib/OpenSRF/Application/Demo/Math.pm +++ b/src/perl/lib/OpenSRF/Application/Demo/Math.pm @@ -20,7 +20,7 @@ sub send_request { my @params = @_; my $session = OpenSRF::AppSession->create( "opensrf.dbmath" ); - my $request = $session->request( "dbmath.$method_name", @params ); + my $request = $session->request( "$method_name", @params ); my $response = $request->recv(); if(!$response) { return undef; } if($response->isa("Error")) {throw $response ($response->stringify);} @@ -37,10 +37,9 @@ sub add_1 { my $client = shift; my @args = @_; - my $meth = $self->method_lookup('_send_request'); - my ($result) = $meth->run('add',@args); - - return $result; + # use ->dispatch rather than run; results of the delegated + # method will be directly passed to the caller + return $self->method_lookup('_send_request')->dispatch('add', @args); } __PACKAGE__->register_method( method => 'sub_1', api_name => 'sub' ); -- 2.43.2