The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::WAMP::Role::Caller - Caller role for Net::WAMP

SYNOPSIS

    package MyWAMP;

    use parent qw( Net::WAMP::Role::Callee );

    sub on_REGISTERED {
        my ($self, $REGISTERED_msg) = @_;
        ...
    }

    sub on_ERROR_REGISTER {
        my ($self, $ERROR_msg, $REGISTER_msg) = @_;
        ...
    }

    sub on_UNREGISTERED {
        my ($self, $UNREGISTERED_msg) = @_;
        ...
    }

    sub on_ERROR_UNREGISTER {
        my ($self, $ERROR_msg, $UNREGISTER_msg) = @_;
        ...
    }

    #----------------------------------------------------------------------

    #NB: The appropriate ERROR message will already have been sent.
    sub on_INTERRUPT {
        my ($self, $INTERRUPT_msg, $interrupter) = @_;

        ...

        #This is optional, useful if you want to return specific
        #information about the interrupted process (e.g., output thus far):
        $interrupter->send_ERROR( {}, \@args, \%args_kw );

        ...
    }

    #----------------------------------------------------------------------

    #See below about $worker_obj:
    sub on_INVOCATION {
        my ($self, $msg, $worker_obj) = @_;
    }

    #----------------------------------------------------------------------

    package main;

    my $wamp = MyWAMP->new( on_send => sub { ... } );

    my $reg_msg = $wamp->send_REGISTER( {}, 'some.procedure.name' );

    $wamp->send_UNREGISTER( $reg_msg->get('Registration') );

    $wamp->send_UNREGISTER_for_procedure( 'some.procedure.name' );

    #This method returns the original REGISTER message object.
    $wamp->get_REGISTER( $INVOCATION_msg );
    $wamp->get_REGISTER( $registration_id );

    #This method returns an INVOCATION object.
    $wamp->get_INVOCATION( $msg );  #e.g., an ERROR or INTERRUPT
    $wamp->get_INVOCATION( $request_id );

    #You *can* do this, but the worker object makes this easier:
    $wamp->send_YIELD( $req_id, {}, \@args, \%args_kv );
    $wamp->send_ERROR( $req_id, {}, $err_uri, \@args, \%args_kv );

DESCRIPTION

Callee is the most complex client class to implement.

The registration stuff follows a straightforward pattern. To answer INVOCATION messages, a special Net::WAMP::RPCWorker class exists to simplify the work a bit.

ANSWERING INVOCATION MESSAGES

As in the SYNOPSIS above, you’ll create a on_INVOCATION() method on your Callee class. That method will accept the arguments shown; $worker_obj is an instance of Net::WAMP::RPCWorker. This special subclass maintains the state of the request and should make life a bit simpler when implementing a Callee.

It is suggested that, for long-running calls, Callee implementations fork() in their on_INVOCATION(), with the child sending the response data back to the parent process, which will then send the data into the RPCWorker object, where it will end up serialized and ready to send back to the router. There is an implementation of this in the Net::WAMP distribution’s demos.