Skip to content

Module Documentation

J.S.I edited this page Dec 9, 2021 · 3 revisions

In the following, the major modules will be described. Primarily, the Publisher and Subscriber modules!

MQTT

M2MqttUnity

As stated background section of the home page of this wiki, DTStacks is built partially on top of the raw integration of the eclipse-paho m2mqtt project for which gpvigano published his raw integration into unity (M2MqttUnity. However, to accommodate a simplified workflow, modifications have been made, primarily to enable less experienced developers to get started without headaches. Or at least less of them. However, it is of course still possible for anyone to further modify these!

Clients

Configuration

All publishers by default (even when created using the publisher generation tool), have a standardized inspector section to configure and establish a connection to a broker. To get hints/clues to each individual field, simply hover the cursor above the name and a tooltip will give a brief description of the field in question.

The meaning and function of all individual fields and options will be described below:


MQTT Broker Configuration

Here all parameters which concern contacting the broker are entered.

string Broker Address

The IP address (if within a local network) or the URL where the Broker is listing at. If a URL is used, use raw URLs without the prefix. Hence, test.mosquitto.org instead of https://test.mosquitto.org or mqtt://test.mosquitto.org. This will be handled internally for you.

int Broker Port

The port at which the Broker is listening. Many Brokers by default listen at port 1883 non-encrypted and 8883 for encrypted

bool Is Encrypted

If enabled, the client will try to establish an TSL/SSL secured connection. For this a certificate is necessary. Using this, the message is significantly more secure than an open connection if sensitive data will be transferred. More information on how to create these certificates can be obtained here


Connection Parameters

int Connection Delay (in [ms])

Specify the delay between activating the component in unity (e.g. at the start of the program) and the establishment of the Mqtt connection

int Timeout On Connect (in [ms])

The period after which the connection will be terminated if no reply from a broker is received.

bool Auto Connect

Instructs the client whether to establish a connection once activated automatically. If this is not enabled, this has to be triggered from another script (e.g. a button on a GUI) to initiate the connecting process. (If nothing seems to be happening, this is a common issue)

string Mqtt User Name

The user name login to access the Broker, if no login is required, simply leave this blank.

string Mqtt Password

The corresponding login-password to access the Broker, if no login is required, simply leave this blank.

string Topic

The topic to which the client listens or publishes to. More information can be found in a post on Steves-Internet-Guide. Please be aware that wildcards are supported but generally not recommended to use in this case.

bool Auto Test

If enabled, the client will automatically send a test message to the specified topic once a connection is established. This is meant as a unit-test for a single client to test the broker connection. Since this is a simple string, it may lead to issues for any subscribed client.


Publisher only

For publishing clients, also the mode of publishing can be configured. (for subscribing clients, this is not necessary.)

bool Is Using Continous Update

If enabled, the publisher will automatically keep publishing the information he has at specified intervals. If this is disabled, the publisher will operate in One-Shot-Mode, meaning the publishing process has to be triggered externally! (E.g. from script or a button on a GUI)

int Update Frames

The interval at which the client will publish a new message to the broker. Counted as "after every Frames".

Publishers

The publisher module is designed to solemnly send the specified information to an MQTT broker. It is NOT intended to be used for processing anything or directly interacting with game objects in Unity. The only interaction it is supposed to have within a unity scene is requesting the relevant information from a dedicated handler.

Clone this wiki locally