mqtt-test

by topniz
See Code Download Embed
MQTT test project with Snap!

This is an advanced example showing connection to a broker.

Quick start :
- hit the green flag
- click on the dot to connect (becomes green)
- hit arrow keys to send messages to your dot: it will move accordingly
- click again on the dot to disconnect

When started, the project prepares the MQTT client. Then, click on the big dot on the stage. It will connect. 
If you click a second time, it will disconnect.

Now, if you use your arrows, the dot wil move accordingly. The dot is not directly commanded by the move actions, but by replying to received messages from the MQTT broker.

If you have access to a different client, you can connect it to the same broker and publish the messages "right", "left", "up" or "down" to the topic "Hello" (attention: with capital H), the dot will move accordingly.

You can load the project on two different computers running Snap!. When you hit the arrow keys on the first computer, the dot on the second computer will follow. 

Finally, don't forget to disconnect your client by clicking again on the dot.

Created February 7, 2019

Last updated May 3, 2020

Published March 12, 2019