Registering Public Responses
Worker APIs
Last updated
Worker APIs
Last updated
A Worker is not coupled to its Caller and therefore a Worker's Caller must register to receive Public Response messages from a Worker. It is up to the Caller to decide whether or not it wants to receive one or more Public Response messages from a Worker.
To register to receive a Public Response message, let's look at the example in the Workers Fundamentals example project of how Worker B sends a Public Response message to Worker A.
Now would be a great time to open the Workers Fundamentals example project which can be found in the Workers tools menu.
The following steps explain how the Public Response message from Worker B was registered with Worker A.
From the block-diagram of Worker A , open the Create MHL Case tool. This tool can be activated from the block diagram of a Worker's Main VI, by use of the Quickdrop Shortcut: Ctrl+9.
Select Add to Response Cases Section (shown below) so that the tool will create a MHL case and add it to the ---RESPONSE CASES--- section of the Worker's MHL case structure.
In the Set Initialization Data VI for Worker B (you will find this VI in Worker A's <Initialize> MHL case as shown below), you need to wire the Case Label that was created for the MHL case in Step 1, to the name of the Public Response in the subWorker's Initialization Data.vi cluster (outlined in red below).
This allows Worker B to know which case of Worker A to send the Public Response message to.
In the MHL case that was created in Worker A to receive the Public Response message, place the Public Response VTD VI (from Worker B) and connect it to the Data terminal of the MHL case structure, as shown in the image below.
This completes the registration process for a Public API Response. Worker B can now send the Public Response message to its Caller (i.e. Worker A). Worker A will receive the Response message in the <Return Number> case of its MHL, and the data in the message will be converted to the correct data type by use of the Public Response VTD VI.