Skip to content

adding a streaming interface #32

Closed
@Tieske

Description

@Tieske

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;

  • new method 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.
  • new callback provided to the client; 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions