Net::WAMP::Role::Broker - Broker role for Net::WAMP
package MyRouter; use parent qw( Net::WAMP::Role::Router ); #For security, this defaults to rejecting everything! sub deny_PUBLISH { my ($self, $SUBSCRIBE_msg) = @_; my $session_obj = $self->get_session(); #success return; #fail, generic (Error = wamp.error.not_authorized) return 1; #fail, custom Auxiliary (Error = wamp.error.not_authorized) return { foo => 1 }; #fail, generic Auxiliary, custom Error return 1, 'myapp.error.go_away'; #fail, custom Auxiliary and Error return { foo => 1 }, 'myapp.error.go_away'; } #This follows the same pattern as deny_PUBLISH(). #It also defaults to rejecting everything. sub deny_SUBSCRIBE { ... }
This is an EXPERIMENTAL WAMP Broker implementation. If you use it, please send feedback!
To have a useful Broker you’ll need to create a deny_PUBLISH method, since the default is to deny all PUBLISH requests. If that Broker is to allow SUBSCRIBE requests, you’ll also need a deny_SUBSCRIBE() method. The format of these is described above.
deny_PUBLISH
deny_SUBSCRIBE()
Broker only exposes a few public methods:
This function subscribes a session to a topic, independently of actual WAMP messaging. This is useful, e.g., if you want to “auto-subscribe” a session to a topic.
The return is the same number that is sent in a SUBSCRIBED message’s Subscription. No SUBSCRIBED message is sent, however.
Subscription
Undoes a subscription, without sending an UNSUBSCRIBED message.
Publish a message. The return is the publication ID, which is sent in the EVENT messages’ Publication.
Publication
To install Net::WAMP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::WAMP
CPAN shell
perl -MCPAN -e shell install Net::WAMP
For more information on module installation, please visit the detailed CPAN module installation guide.