The Perl Toolchain Summit 2025 Needs You: You can help 🙏 Learn more

NAME

Net::WAMP::Role::Subscriber - Subscriber role for Net::WAMP

SYNOPSIS

package MyWAMP;
sub on_EVENT {
my ($self, $msg, $SUBSCRIBE_msg) = @_;
...
}
sub on_SUBSCRIBED {
my ($self, $msg, $SUBSCRIBE_msg) = @_;
...
}
sub on_ERROR_SUBSCRIBED {
my ($self, $ERROR_msg, $SUBSCRIBE_msg) = @_;
...
}
sub on_UNSUBSCRIBED {
my ($self, $msg, $UNSUBSCRIBE_msg, $SUBSCRIBE_msg) = @_;
...
}
sub on_ERROR_UNSUBSCRIBED {
my ($self, $ERROR_msg, $UNSUBSCRIBE_msg, $SUBSCRIBE_msg) = @_;
...
}
package main;
my $wamp = MyWAMP->new( on_send => sub { ... } );
$wamp->send_SUBSCRIBE( {}, 'some.topic' );
$wamp->send_UNSUBSCRIBE( $subscr_id );
#A more convenient alternative to send_UNSUBSCRIBE
#so you don’t have to track the subscription ID yourself:
$wamp->send_UNSUBSCRIBE_for_topic( 'some.topic' );
$wamp->get_SUBSCRIBE( $msg ); #e.g., an EVENT message object
$wamp->get_SUBSCRIBE( $subscr_id );

DESCRIPTION

See the main Net::WAMP documentation for more background on how to use this class in your code.