Altova MobileTogether Designer

MobileTogether's Broadcasts feature enables one or more solutions to broadcast messages to a topic. These messages are delivered via MobileTogether Server to all connected MobileTogether solutions that have been subscribed to this topic. Note that only MobileTogether solutions can participate in broadcasts. This is different than MQTT, where messages are published via an MQTT broker and any device—not only MobileTogether solutions—can participate.

 

Publish, subscribe

Publishing and subscribing is straightforward and each is achieved by triggering its respective action:

 

To publish a broadcast message, the Publish Broadcast Message action is defined. It has two settings: (i) the topic under which messages are broadcast; (ii) the text of the message to broadcast. When the action is triggered, the message is broadcast and will be delivered to all connected subscriber solutions.

To receive a broadcast message, a solution must subscribe to the relevant topic—defined in the Subscribe Broadcast Topic action. After the Subscribe action is triggered, the solution will start receiving messages published to the subscribed topic.

The Unsubscribe Broadcast Topic action enables you to stop a solution receiving messages of the specified topic. Note that the receipt of messages will also stop if a solution is no longer connected to MobileTogether Server. In case a solution stops receiving the messages of a given topic—either because of an Unsubscribe action or a lost connection—then a Subscribe action to that topic must be triggered for the solution to again receive messages from that topic.

 

Note:Broadcast messages must be strings.

 

Actions on message received

When a broadcast message is received in a solution, (i) the message is stored in the solution's $MT_Broadcast dynamic variable and (ii) the action tree of OnBroadcastReceive is executed.

 

A $MT_Broadcast variable is declared for each received broadcast message. It contains the text of the received message and can be used in the action tree of that received message. The message held in $MT_Broadcast cannot be accessed after the OnBroadcastReceive action tree has finished executing. So if you want to use the received message at a later time, you should add an action to the OnBroadcastReceive action tree that stores the received message in a page source node. After the action tree has been executed, the $MT_Broadcast variable will no longer exist. A new $MT_Broadcast variable will be declared when the next broadcast message is received.

 

The action tree of OnBroadcastReceive is available at two levels:

 

At the page level, in the OnBroadcastReceive page event. The action tree is accessed either via the Page Actions property (in the Styles & Properties Pane) or via the Page Actions dialog (via the context menu of the page in the design).

At the project level, via the Broadcast Actions project property.

 

You can define the actions to perform at either of these levels or at both levels. If an action tree has been defined at the page level for the active page, then this is executed. Otherwise, the action tree at the project level is executed—if such a tree exists. If no action has been defined at either level, then nothing happens when a broadcast message is received.

 

Simulate actions on message received

You can simulate what happens when a Broadcast message is received. Press F5 to start the simulator (screenshot below).

MTDSimulatorOnMsgsReceivedBroadcast

To simulate messages received, we use an XML sample file that is located by default in your MobileTogether Designer application folder. See the Options dialog (Simulation 2 tab) for the file path to this file. This file contains XML data that simulates messages received. So you can use it to test the action tree that will be executed when a message is received.

 

Note:If the XML sample file is in a write-protected folder (which is often the case with Windows application folders), you might need to open MobileTogether Designer with administrator privileges. This would enable you to save changes to the sample data (about which see below). To start MobileTogether Designer as an administrator, right-click its shortcut in Windows and select the command to start it as an administrator.

 

Start the MobileTogether Designer simulator by pressing F5. In the simulator, use the Simulate Reception of Message toolbar button (circled green in the screenshot above) to open the Messages dialog.

 

In the dialog that appears, you can do the following:

 

In the Messages dialog (screenshot below), the data displayed in the dialog's table is the data in the XML sample file. Each row represents one received message. The Content column contains the text of the message.

MTDSimulateMQTTBroadcastMsgRcd

To simulate the reception of a message in the solution, select a message row and click Send and Close. The action tree of the solution will be executed with the data of the selected message and you can check whether actions were executed as you wanted. In the Messages dialog (screenshot above), you can edit the descriptions of messages and also delete a selected message. If you click Save after making changes, then the changes will be saved back to the XML sample file.

 

The messages from the sample XML file are also available in the dropdown list of the Simulate Reception of Message toolbar button. Select a message in the dropdown list to simulate its receipt. Additionally, you can record a new message by first toggling on Record a message in the dropdown list of commands and then simulating the sending and receipt of a message. Whatever messages are sent while the recording is toggled on will be displayed in the Messages table (screenshot above). You can modify the descriptions as required and save the messages back to the XML sample file.

 

© 2018-2024 Altova GmbH