-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding a streaming interface #32
Comments
@Tieske, please take a look at the Connectors topic - https://github.com/xHasKx/luamqtt#connectors read_func (recv_func) is created inside MQTT client code here: For now, that approach allows me to integrate several connectors from different runtime environments (luasocket, copas, nginx). But of course you can suggest a better way to decouple network streams reading logic, if it leave the MQTT protocol parsing code in the same form. |
Yes, after spending quite some time reading the code, I noticed that. But I also ran into some other issues, there are hardcoded error messages in the
The code in |
So I've been updating code, but unfortunately the changes were bigger than I anticipated (sorry about that 😞 ). I'll push the code to #31 shortly. |
closing this in favor of #31 |
Hi @xHasKx
Thx for this nice library, I've been eyeballing MQTT for a while now, and thought to give it a go actually.
The code looks nice and clean, but what I'm missing is a streaming interface. Looking at the code, currently
client.lua
mixers client functionality with io-loop functionality. Which isn't the right separation of concerns imho.So would you be interested in a streaming interface? I've seen another issue about blocking IO (#23 ). So what I would propose to separate the client from the runloop is along the following lines;
client:consume_bytes(byte_string)
. This means the client is no longer responsible for reading data, only for processing it. Any runloop can read data in whatever way it sees fit, and then feed that into this method.send_bytes(byte_string)
. Whenever the client needs to send data, it calls this callback with the data to be transmitted.This way the client and the runloop are cleanly decoupled.
wdyt?
as a start I sent a PR (#31 ) to expose the keepalive functionality to external runloops.
The text was updated successfully, but these errors were encountered: