[fpc-pascal] MQTT package for freepascal/lazarus?
Jean SUZINEAU
jean.suzineau at wanadoo.fr
Mon Oct 24 15:38:29 CEST 2022
Le 23/10/2022 à 23:59, Bo Berglund via fpc-pascal a écrit :
> Might get stuck at readln(s) if no messages are sent, i.e. no carriage-return
> coming along?
> AFAIK readln is blocking, right?
I've made a test with mosquitto_pub, it seems there is a line ending at
the end of each message, so you will be blocked only when there are no
new message available.
If your program needs to do something else during the wait for a new
message, you'll need to dedicate a thread or a separate program.
Maybe dedicate a thread, putting your Readln (in the case of
mosquitto_sub ... |SomePascalProgram) or the loop (in the case of use
of TProcess) in your TThread descendant Execute method.
There you when you receive a new mqtt message you can call
TThread.Synchronize (on a method of your forms for example) to process
the message in your main thread.
More information about the fpc-pascal
mailing list