Kanzi Connect service plugins

You can use the Kanzi Connect service plugins to access the Kanzi Connect services from the application user interface.

The plugin modules provide Kanzi objects that you can attach to nodes in the UI node tree and enable them to communicate with the services.

The plugin modules provide these types of plugin objects:

  • Actions. Use actions to call a service method with arguments. For example, a button that performs a Media:playTrack action.

  • Triggers. Use triggers to receive an event from the service. For example, a popup window that is displayed when an event occurs on a Kanzi Connect server.

  • Data sources. Use data sources to get runtime data and content. See Kanzi Connect data source.

When Kanzi Engine starts and loads the service plugin modules, the services that are used in the plugin module need to be registered to the Context object. This allows the Kanzi Connect Client to recognize the network interface of the services and allows the plugin objects to communicate with their server-side service component.

The Service interface is exposed to Kanzi Studio as follows:

  • For every service, there is a category. For example, Media.

  • For every method in the service, there is an action and argument property types. For example, Media:playPlaylist, Media.playPlaylist.playlistId.

  • For every event in the service, there is a trigger. For example, Media:progress.

  • For every data field, there is a matching entry on the server-side content database that allows accessing the runtime data of the service.

This has a direct mapping to the service interface definition XML that defines the interface for a service.

Modifying the connect_services plugin

Modify the connect_services plugin when you want to:

  • Add service clients

  • Run your Kanzi Connect application on a target with limited memory and want to decrease the binary size of your application by removing the Kanzi Connect functionality that you do not need

  • Have introspected and binary client for a service

Kanzi Connect SDK includes a Kanzi Engine plugin that contains generic clients for introspected services and the Kanzi Connect data source. The library of this plugin has thin implementation and Kanzi Connect uses it to bind the functionality that exists in other libraries. In this way Kanzi Connect enables the modification of existing and addition of new functionality while maintaining the application template structure.

To exclude modules from the connect_services plugin, in the <KanziConnectInstallation>/SDK/build/configs/platforms/common/config.py add to the dependency_exclude list the modules whose functionality you want to exclude, and run the script. Kanzi Connect uses this script to create the connect_services.dll from the <KanziConnectInstallation>/SDK/sources/engineplugins/connect_services/plugins_module.cpp. For example, to exclude the functionality of modules viewports, http_loaders, adapter_ssl, adapter_udp, and adapter_shm:

# Local suppression of modules not needed within project. Supported values (separated with comma):
# "viewports"    - Multimedia libraries
# "http_loaders" - HTTP protocol handlers, adds curl and openssl libraries
# "adapter_tcp"  - connect.bearer.tcp, reducing code size
# "adapter_ssl"  - connect.bearer.ssl, openssl libraries have significant effect on library loading time and size
# "adapter_shm"  - connect.bearer.shm, reducing code size
# "adapter_udp"  - connect.bearer.udp, reducing code size, libENET
if not platform_name.startswith("integrity_"):
    dependency_excludes = []
else:
    dependency_excludes = ['viewports','http_loaders','adapter_ssl','adapter_udp','adapter_shm']

To add functionality to the connect_services plugin:

  1. In the <KanziConnectInstallation>/SDK/build/configs/platforms/common/config.py define the libraries or source files that you want to add.

  2. In the <KanziConnectInstallation>/SDK/sources/engineplugins/connect_services/plugins_module.cpp add the metaclass factories.

    PluginsModule::MetaclassContainer PluginsModule::getMetaclassesOverride()
    {
        MetaclassContainer metaclasses;
        metaclasses.push_back(MyConnectAction::getStaticMetaclass());
        // ...
    
  3. If you introduce service clients that require implementation, such as those that you cannot use through generic introspection clients, register your client interface in the Kanzi Connect Context service cache. To do this, add the creator function of your interface to <KanziConnectInstallation>/SDK/sources/engineplugins/connect_services/plugins_module.cpp.

    void PluginsModule::registerMetadataOverride(ObjectFactory& factory)
    {
        getContext()->registerService(MyServiceClient::Type(), MyServiceClient::create);
        // ...
        Plugin::registerMetadataOverride(factory);
    
  4. Build the connect_services plugin:

    For example, to build for linux_x11_glx with scons build:

    Go to <KanziConnectInstallation>/SDK/build/configs/platforms/common/linux_x11_glx.

    scons Release GL project_name=connect_services --dynamic
    

    to build for Win64 GL_vs2019_Release_DLL:

    Go to <KanziConnectInstallation>/SDK/sources/engineplugins.

    py -3 ..\..\build_app.py . win64 --config GL_vs2019_Release_DLL --gfx_api GL --dynamic
    

    to build for android_gradle:

    Either go to <KanziConnectInstallation>/SDK/sources/engineplugins.

    py -3 ..\..\build_app.py . android_gradle --config Release --gfx_api ES3 --dynamic
    

    Or go to <KanziConnectInstallation>/SDK/sources/engineplugins/configs/platforms/android_gradle.

    gradlew.bat assembleRelease
    

See also

Kanzi Connect services

Tutorial: Create a custom Kanzi Connect service

Tutorial: Create a Kanzi Connect application