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.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to