M2MqttUnity  1.0
M2MQTT for Unity
M2MqttUnity.Examples.M2MqttUnityTest Class Reference

Script for testing M2MQTT with a Unity UI More...

Inheritance diagram for M2MqttUnity.Examples.M2MqttUnityTest:
M2MqttUnity.M2MqttUnityClient

Public Member Functions

void TestPublish ()
 
void SetBrokerAddress (string brokerAddress)
 
void SetBrokerPort (string brokerPort)
 
void SetEncrypted (bool isEncrypted)
 
void SetUiMessage (string msg)
 
void AddUiMessage (string msg)
 
- Public Member Functions inherited from M2MqttUnity.M2MqttUnityClient
virtual void Connect ()
 Connect to the broker using current settings. More...
 
virtual void Disconnect ()
 Disconnect from the broker, if connected. More...
 

Public Attributes

bool autoTest = false
 
InputField consoleInputField
 
Toggle encryptedToggle
 
InputField addressInputField
 
InputField portInputField
 
Button connectButton
 
Button disconnectButton
 
Button testPublishButton
 
Button clearButton
 
- Public Attributes inherited from M2MqttUnity.M2MqttUnityClient
string brokerAddress = "localhost"
 
int brokerPort = 1883
 
bool isEncrypted = false
 
int connectionDelay = 500
 
int timeoutOnConnection = MqttSettings.MQTT_CONNECT_TIMEOUT
 
bool autoConnect = false
 

Protected Member Functions

override void OnConnecting ()
 Ovverride this method to take some actions before connection (e.g. More...
 
override void OnConnected ()
 Override this method to take some actions if the connection succeeded. More...
 
override void SubscribeTopics ()
 Ovverride this method to subscribe to MQTT topics. More...
 
override void UnsubscribeTopics ()
 Ovverride this method to unsubscribe to MQTT topics (they should be the same you subscribed to with SubscribeTopics() ). More...
 
override void OnConnectionFailed (string errorMessage)
 Override this method to take some actions if the connection failed. More...
 
override void OnDisconnected ()
 Override this method to take some actions when disconnected. More...
 
override void OnConnectionLost ()
 Override this method to take some actions when the connection is closed. More...
 
override void Start ()
 Connect on startup if autoConnect is set to true. More...
 
override void DecodeMessage (string topic, byte[] message)
 Override this method for each received message you need to process. More...
 
override void Update ()
 Processing of income messages and events is postponed here in the main thread. More...
 
- Protected Member Functions inherited from M2MqttUnity.M2MqttUnityClient
virtual void OnApplicationQuit ()
 Disconnect before the application quits. More...
 
virtual void Awake ()
 Initialize MQTT message queue Remember to call base.Awake() if you override this method. More...
 
virtual void ProcessMqttEvents ()
 

Additional Inherited Members

- Protected Attributes inherited from M2MqttUnity.M2MqttUnityClient
MqttClient client
 Wrapped MQTT client More...
 
- Events inherited from M2MqttUnity.M2MqttUnityClient
Action ConnectionSucceeded
 Event fired when a connection is successfully estabilished More...
 
Action ConnectionFailed
 Event fired when failing to connect More...
 

Detailed Description

Script for testing M2MQTT with a Unity UI

Member Function Documentation

◆ AddUiMessage()

void M2MqttUnity.Examples.M2MqttUnityTest.AddUiMessage ( string  msg)

◆ DecodeMessage()

override void M2MqttUnity.Examples.M2MqttUnityTest.DecodeMessage ( string  topic,
byte []  message 
)
protectedvirtual

Override this method for each received message you need to process.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ OnConnected()

override void M2MqttUnity.Examples.M2MqttUnityTest.OnConnected ( )
protectedvirtual

Override this method to take some actions if the connection succeeded.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ OnConnecting()

override void M2MqttUnity.Examples.M2MqttUnityTest.OnConnecting ( )
protectedvirtual

Ovverride this method to take some actions before connection (e.g.

display a message)

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ OnConnectionFailed()

override void M2MqttUnity.Examples.M2MqttUnityTest.OnConnectionFailed ( string  errorMessage)
protectedvirtual

Override this method to take some actions if the connection failed.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ OnConnectionLost()

override void M2MqttUnity.Examples.M2MqttUnityTest.OnConnectionLost ( )
protectedvirtual

Override this method to take some actions when the connection is closed.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ OnDisconnected()

override void M2MqttUnity.Examples.M2MqttUnityTest.OnDisconnected ( )
protectedvirtual

Override this method to take some actions when disconnected.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ SetBrokerAddress()

void M2MqttUnity.Examples.M2MqttUnityTest.SetBrokerAddress ( string  brokerAddress)

◆ SetBrokerPort()

void M2MqttUnity.Examples.M2MqttUnityTest.SetBrokerPort ( string  brokerPort)

◆ SetEncrypted()

void M2MqttUnity.Examples.M2MqttUnityTest.SetEncrypted ( bool  isEncrypted)

◆ SetUiMessage()

void M2MqttUnity.Examples.M2MqttUnityTest.SetUiMessage ( string  msg)

◆ Start()

override void M2MqttUnity.Examples.M2MqttUnityTest.Start ( )
protectedvirtual

Connect on startup if autoConnect is set to true.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ SubscribeTopics()

override void M2MqttUnity.Examples.M2MqttUnityTest.SubscribeTopics ( )
protectedvirtual

Ovverride this method to subscribe to MQTT topics.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ TestPublish()

void M2MqttUnity.Examples.M2MqttUnityTest.TestPublish ( )

◆ UnsubscribeTopics()

override void M2MqttUnity.Examples.M2MqttUnityTest.UnsubscribeTopics ( )
protectedvirtual

Ovverride this method to unsubscribe to MQTT topics (they should be the same you subscribed to with SubscribeTopics() ).

Reimplemented from M2MqttUnity.M2MqttUnityClient.

◆ Update()

override void M2MqttUnity.Examples.M2MqttUnityTest.Update ( )
protectedvirtual

Processing of income messages and events is postponed here in the main thread.

Remember to call ProcessMqttEvents() in Update() method if you override it.

Reimplemented from M2MqttUnity.M2MqttUnityClient.

Member Data Documentation

◆ addressInputField

InputField M2MqttUnity.Examples.M2MqttUnityTest.addressInputField

◆ autoTest

bool M2MqttUnity.Examples.M2MqttUnityTest.autoTest = false

◆ clearButton

Button M2MqttUnity.Examples.M2MqttUnityTest.clearButton

◆ connectButton

Button M2MqttUnity.Examples.M2MqttUnityTest.connectButton

◆ consoleInputField

InputField M2MqttUnity.Examples.M2MqttUnityTest.consoleInputField

◆ disconnectButton

Button M2MqttUnity.Examples.M2MqttUnityTest.disconnectButton

◆ encryptedToggle

Toggle M2MqttUnity.Examples.M2MqttUnityTest.encryptedToggle

◆ portInputField

InputField M2MqttUnity.Examples.M2MqttUnityTest.portInputField

◆ testPublishButton

Button M2MqttUnity.Examples.M2MqttUnityTest.testPublishButton

The documentation for this class was generated from the following file: