Appearance
Plugin policy
A plugin policy file is a configuration file used both by the Plugin itself and any other Consumer:
Plugins "
plugin-policy.json"Configure this plugin to be able to publish messages to the outside world.
👍 You can also subscribe to receive messages from the outside world.
Consumers "
plugin-policy.json"Either the host App, or other plugins, can subscribe to messages from the outside world.
👍 You can also publish messages to the outside world inside plugins.
:::caution
The host App cannot publish messages, only plugins can do. So if you want to send a message via PlatformHub from your host App, create a plugin that lives as close as possible to it and send the messages through it.
:::
Name
json
{
"name": "NamePlugin",
"version": "0.1"
// ...
}The name property is an important part of the plugin. For more information see the Policy Plugin Name Conventions section
TIP
It should be consistent with the > Naming guidelines.
Understand plugin messages
json
{
"publish": {
"eventStreams": []
},
"subscribeOnStartup": {
"eventStreams": []
},
"subscribeOnDemand": {
"eventStreams": []
},
"send": {
"commands": [],
"navigationQueries": [],
"queries": []
},
"receive": {
"commands": [],
"navigationQueries": [],
"queries": []
},
"publishToTopic": {
"topicStreams": []
},
"subscribeToTopic": {
"topicStreams": []
}
}The publish and send properties in the json file, allow plugins to publish and send messages transmitted via platformhub The subscribeOnStartup, subscribeOnDemand and receive properties in the json file, allow consumers to subscribe to messages transmitted via PlatformHub. Messages transmitted using publish can be subscribed by many plugins. Messages transmitted using send can only be receive by one plugin.
:::note
The subscribeOnDemand block allow plugins to subscribe to events on-demand by invoking
kotlin
messageSender.subscribeOnDemand(event: BaseMessage.Event, subscriber: Plugin):::
INFO
messages can be sent with an optional payload attached to it in case we need to pass any information to its receiver. Payloads are JSONObjects.
To view the structure of the policy file, please click on the links below: