Module: caf_pubsub/proxy_pubsub

Proxy that allows a CA to access a publish/subscribe service.

Source:

Extends

Methods

publish(topic, value)

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 <ca_name>- or forum- depending on the type of channel.

value string

A message to be published.

Source:
Throws:

Error If topic has an invalid prefix.

subscribe(topic, methodName)

Subscribes to a topic.

It also identifies a method name in this CA with signature:

 function(topic:string, value:string, callback:cbType)

that will process new published events in that topic.

Note that pub/sub notifications use standard messages and, therefore, standard method ACLs can be applied to restrict publishers.

Parameters:
Name Type Description
topic string

A topic to subscribe.

methodName string

A method name to handle new events of that topic.

Source:

unsubscribe(topicopt)

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 undefined).

Source: