Viz Plug-ins User Guide

Version 5.0 | Published December 20, 2022 ©

Plug-in API

Callbacks

PLUGIN_EXTENSION_CONFIGURE

Signature

int PLUGIN_EXTENSION_CONFIGURE(void* pvDataPtr, const char* configStr)

Required

No

Description

Called to configure the extension plug-in. This function is called if a configuration file for this extension exists with a <configStr> parameter.

PLUGIN_EXTENSION_CONFIG_GET

Signature

const char* PLUGIN_EXTENSION_CONFIG_GET(void* pvDataPtr)

Required

No

Description

Called to get the current configuration of the extension plug-in. The return value is expected to be the content of the serialized configuration.

PLUGIN_REQUEST

Signature

void PLUGIN_REQUEST(void* pvDataPtr, int connection, const char* location, const char* msg)

Required

No

Description

Called whenever a message is received for this extension.

Note: This function is always called on the main thread.

  • connection: object-id of sender (must be used for _api__respond)

  • location: message endpoint

  • msg: message payload

PLUGIN_RESPONSE

Signature

void PLUGIN_RESPONSE(void* pvDataPtr, const char* location, const char* msg)

Required

No

Description

Callback for incoming responses [Messages].

Note: This function is always called on the main thread.

After calling _api__request this function is called with the response message.

  • location: message endpoint

  • msg: message payload

Functions

_api__get_plugin_objectid

Signature

int _api__get_plugin_objectid();

Description

Returns the object ID of the current plug-in. Can be used for _api__request.

_api__request

Signature

void _api__request(int iObjectID, const char* location, const char* msg)

Description

Sends a message request.

Note: Function can be called at any time and is thread-safe.

  • iObjectID: object-id of the current plug-in. Can be retrieved by calling _api__get_plugin_objectid.

  • location: Message endpoint

  • msg: optional message payload

Example: If an extension provides a message endpoint of "/Extensions/Sample/greet".

You could make a requests with _api__request(myObjectId, "/Extensions/Sample/greet", "")


_api__respond

Signature

void _api__respond(int iObjectID, const char* location, const char* msg);

Description

Can be used to respond to a message request. If a message is received by getting PLUGIN_REQUEST called. You can respond with this function (immediately or at another time).

  • iObjectID: object-id which got passed by PLUGIN_REQUEST

  • location: location which got passed by PLUGIN_REQUEST

  • msg: the response message body

Note: Function can be called at any time and is thread-safe.