Show
Ignore:
Timestamp:
06/21/08 02:39:48 (5 years ago)
Author:
nothingmuch
Message:

allow object handler too (can't be async though)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/POE-Component-Server-JSONRPC/trunk/lib/POE/Component/Server/JSONRPC.pm

    r14290 r14323  
    8484 
    8585has handler => ( 
    86     isa => "CodeRef|Str|HashRef", 
     86    isa => "CodeRef|Str|HashRef|Object", 
    8787    is  => "rw", 
    8888); 
     
    224224            } 
    225225 
    226             my $cb = sub { 
    227                 if ( do { local $@; eval { $_[0]->does("JSON::RPC::Common::Message") } } ) { 
    228                     $client->put($_[0]); 
     226            if ( blessed $handler ) { 
     227                $client->put( $call->call($handler) ) 
     228            } else { 
     229                my $cb = sub { 
     230                    if ( do { local $@; eval { $_[0]->does("JSON::RPC::Common::Message") } } ) { 
     231                        $client->put($_[0]); 
     232                    } else { 
     233                        $client->put( $msg->return_result(@_) ); 
     234                    } 
     235                }; 
     236 
     237                if ( ref $handler ) { 
     238                    $handler->( $cb, $msg, $client ); 
    229239                } else { 
    230                     $client->put( $msg->return_result(@_) ); 
     240                    $kernel->post( $self->_parent, $handler, $cb, $msg, $client ); 
    231241                } 
    232             }; 
    233  
    234             if ( ref $handler ) { 
    235                 $handler->( $cb, $msg, $client ); 
    236             } else { 
    237                 $kernel->post( $self->_parent, $handler, $cb, $msg, $client ); 
    238242            } 
    239243        } else {