Object -
websub
:
Hub
Represents the Ballerina WebSub Hub.
Constructor
__init
(string subscriptionUrl, string publishUrl, Listener hubHttpListener)
Methods
Stops the started up Ballerina WebSub Hub.
Publishes an update against the topic in the initialized Ballerina Hub.
Registers a topic in the Ballerina Hub.
Unregisters a topic in the Ballerina Hub.
Removes a subscription from the Ballerina Hub, without verifying intent.
Retrieves topics currently recognized by the Hub.
Retrieves details of subscribers registered to receive updates for a particular topic.
Fields
- subscriptionUrl string
-
The URL for subscription changes
- publishUrl string
-
The URL for publishing and topic registration
Stops the started up Ballerina WebSub Hub.
error? registrationResponse = webSubHub.stop();
-
Return Type
(error?) An
error
if hub can't be stoped or else()
publishUpdate
(string topic, string | xml | json | byte[] | ReadableByteChannel payload, string? contentType)
returns error?Publishes an update against the topic in the initialized Ballerina Hub.
error? publishResponse = webSubHub.publishUpdate("http://websubpubtopic.com",{"action": "publish",
"mode": "internal-hub"});
Parameters
- topic string
-
The topic for which the update should happen
- payload string | xml | json | byte[] | ReadableByteChannel
-
The update payload
- contentType string? (default ())
-
The content type header to set for the request delivering the payload
-
Return Type
(error?) An
error
if the hub is not initialized or does not represent the internal hub or else()
Registers a topic in the Ballerina Hub.
error? registrationResponse = webSubHub.registerTopic("http://websubpubtopic.com");
Parameters
- topic string
-
The topic to register
-
Return Type
(error?) An
error
if an error occurred with registration or else()
Unregisters a topic in the Ballerina Hub.
error? registrationResponse = webSubHub.unregisterTopic("http://websubpubtopic.com");
Parameters
- topic string
-
The topic to unregister
-
Return Type
(error?) An
error
if an error occurred with unregistration or else()
Removes a subscription from the Ballerina Hub, without verifying intent.
error? registrationResponse = webSubHub.removeSubscription("http://websubpubtopic.com", "removeSubscriptioCallback");
Parameters
- topic string
-
The topic for which the subscription should be removed
- callback string
-
The callback for which the subscription should be removed
-
Return Type
(error?) An
error
if an error occurred with removal or else()
Retrieves topics currently recognized by the Hub.
string[] topic = webSubHub.getAvailableTopics();
-
Return Type
(string[]) An array of available topics
Retrieves details of subscribers registered to receive updates for a particular topic.
string[] topic = webSubHub.getSubscribers("http://websubpubtopic.com");
Parameters
- topic string
-
The topic for which details need to be retrieved
-
Return Type
(SubscriberDetails[]) An array of subscriber details