xHasKx / luamqtt

luamqtt - Pure-lua MQTT v3.1.1 and v5.0 client
https://xhaskx.github.io/luamqtt/
MIT License
152 stars 41 forks source link

Connector for Socket Library that only reports Status through Callbacks #47

Open gschellhas opened 2 months ago

gschellhas commented 2 months ago

I am working in an environment that doesn't have access to Lua rocks and doesnt have access to luasockets.

The Library I have access to is a TcpSocket, found here. https://q-syshelp.qsc.com/#Control_Scripting/Using_Lua_in_Q-Sys/TcpSocket.htm

The library is not blocking, and the environment does not allow me to block either. I have access to a Timer library found here that utilizes callbacks. https://q-syshelp.qsc.com/#Control_Scripting/Using_Lua_in_Q-Sys/Timer.htm?TocPath=Design%257CControl%2520Scripting%257CQ-SYS%2520Extensions%2520to%2520Lua%257C_____34

Can you see a way to create a connector with this? Thank you,

Tieske commented 2 months ago

That's a tough problem. This library is tightly coupling the runloop (and sockets) to the protocol implementation.

I did work on that to decouple them, see: #31 . It facilitates both blocking as well as non-blocking (== coroutine yielding) sockets. I completely rewrote the connectors there. But not sure it would be possible to handle callback based sockets.

You might want to have a look at https://luarocks.org/modules/fperrad/lua-mqtt which (afaik) only implements the protocol, not the sockets.

gschellhas commented 2 months ago

I was able to get it working but with some heavy lifting, and modification of the code. I can post my fork of the project, and maybe it will spark some ideas. Thank you!

From: Thijs Schreijer @.> Sent: Wednesday, June 19, 2024 4:31 PM To: xHasKx/luamqtt @.> Cc: Schellhas, Gary @.>; Author @.> Subject: Re: [xHasKx/luamqtt] Connector for Socket Library that only reports Status through Callbacks (Issue #47)

That's a tough problem. This library is tightly coupling the runloop (and sockets) to the protocol implementation.

I did work on that to decouple them, see: #31https://github.com/xHasKx/luamqtt/pull/31 . It facilitates both blocking as well as non-blocking (== coroutine yielding) sockets. I completely rewrote the connectors there. But not sure it would be possible to handle callback based sockets.

You might want to have a look at https://luarocks.org/modules/fperrad/lua-mqtt which (afaik) only implements the protocol, not the sockets.

- Reply to this email directly, view it on GitHubhttps://github.com/xHasKx/luamqtt/issues/47#issuecomment-2179421446, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AKJYLYJ5VDBBPRHVIKTHBUDZIHS6NAVCNFSM6AAAAABJSTOWHWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZZGQZDCNBUGY. You are receiving this because you authored the thread.Message ID: @.**@.>>