Hello,
I am trying to implement mqtt support into a mudclient (Mudlet) that has lua as its backend script language. And i have almost gotten it to work the way i want it to using luamqtt. My challenge seem to be with the ioloop. If i run the ioloop the way the examples describe, I will basically crash the mudclient as the ioloop is blocking the "main thread" from executing.
I managed to get past this issue, by not running ioloop, but rather setting up a timer that run the client:_ioloop_iteration() at a fixed interval. This works ok'ish when i run it at 1 second period. Now i can publish, and subscribe to messages in Mudlet.
I would have preferred to run it faster though, as the client is "sluggish" when receiving external messages (understandably) with a 1 second period.
I did try to run the client:_ioloop_iteration() at 100ms instead, but then i had masive crashes again...
I guess my question is: Am i doing it wrong? Can i run the ioloop wihtout it crashing the main thread? Or if i need to run the ioloop manually, is this the correct way to do it, by manually calling _ioloop_iteration() at a fixed interval? Or is there a better way, calling some method that will check the inbound queue, fire the callbacks then exit without looping?
Thanks and regards!