NAME
Net::WAMP::Role::Broker - Broker role for Net::WAMP
SYNOPSIS
package
MyRouter;
#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 { ... }
DESCRIPTION
This is an EXPERIMENTAL WAMP Broker implementation. If you use it, please send feedback!
AUTHORIZATION
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.
METHODS
Broker only exposes a few public methods:
$subscr_id = OBJ->subscribe( SESSION_OBJ, METADATA_HR, TOPIC )
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.
OBJ->unsubscribe( SESSION_OBJ, SUBSCR_ID )
Undoes a subscription, without sending an UNSUBSCRIBED message.
OBJ->publish( SESSION_OBJ, METADATA_HR, TOPIC );
OBJ->publish( SESSION_OBJ, METADATA_HR, TOPIC, @ARGS );
OBJ->publish( SESSION_OBJ, METADATA_HR, TOPIC, @ARGS, %ARGS_KV );
Publish a message. The return is the publication ID, which is sent in the EVENT messages’ Publication
.