Cloud variables with MQTT

https://snap.berkeley.edu/snap/snap.html#present:Username=d4s_over_dt4&ProjectName=mqtt
(I know that having to go to server once and set the variable before broadcasting it is both very silly and very slow,but that's why its not a snap library and mqtt is)
Variable latency:480~560 ms
You must use the forever loop in the variable section to receive variables.

Just after making this,I thought of a new way of doing it
https://snap.berkeley.edu/snap/snap.html#present:Username=d4s_over_dt4&ProjectName=mqtt2
Latency:246~288ms

(not read 2nd approach yet) but the idea of MQTT is to subscribe once and then let the the on each message script in the grey ring do the work required when a message is received - not to re-subscribe in a loop

Yep - that's the way to do it :slight_smile:

Yeah,that's why i did the second approach which you didn't complain of

#TopTip - use a reasonably unique topic name on a public broker (even when testing) because a lot of people use these brokers and namespace clashes are easily possible :slight_smile:

Okay.

ps:the probelm in my first approach was to simulate a server-client setup with mqtt,and that defys the reason of using mqtt

And just a heads up - there's been a little issue discovered with the subscribe block which causes a payload of something like España to be be output as España

It has been fixed in the upcoming release but is present at the moment

Normal letters < unicode value of 128 are fine

Oh...okay?

Yes :slight_smile:

MQTT makes sharing things easy :slight_smile:

I made a new project:
https://snap.berkeley.edu/snap/snap.html#present:Username=d4s_over_dt4&ProjectName=mqtt%20cooperation
But this is not going into cooperation totm cuz packet mode is far more efficeint here