Proxy that allows a CA to access a publish/subscribe service.
- Source:
Extends
Methods
publish(topic, value)
- Source:
Publishes a new value for a topic in a pubsub channel.
The channel is implicitly created the first time is used.
There are two types of channels:
- A personal channel is prefixed by the CA name, i.e.,
<ca_name>-<whatever>
, and only that CA can publish messages. - A forum channel has a name of the form
forum-<whatever>
, and anybody can publish to it.
Parameters:
Name | Type | Description |
---|---|---|
topic |
string | A topic for the published message. It should have
a prefix |
value |
string | A message to be published. |
Throws:
Error If topic has an invalid prefix.
subscribe(topic, methodName)
- Source:
Subscribes to a topic.
It also identifies a method name in this CA with signature:
function(topic:string, value:string, from: string, callback:cbType)
or
async function(topic:string, value:string, from: string)
that will process published events using that topic.
Note that pub/sub notifications use standard messages and standard method ACLs can be applied to restrict publishers.
It is recommended to use an internal method, i.e., one that starts
with prefix __ca_
. Internal methods are safer because requests always
come from the trusted
bus and not from external sessions, i.e., the request came
from a call to publish()
in the app, and not from arbitrary code.
Note that this.$.security.getCallerFrom()
does not provide the real
caller for internal methods, use the from
argument instead.
Parameters:
Name | Type | Description |
---|---|---|
topic |
string | A topic to subscribe. |
methodName |
string | A method name to handle new events of that topic. See the discussion on internal methods above. |
unsubscribe(topicopt)
- Source:
Unsubscribes from a topic (or all if topic is undefined)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
topic |
string |
<optional> |
A topic to unsubscribe (or all
topics if |