xHasKx / luamqtt

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

Draft copas support #26

Closed dvv closed 3 years ago

dvv commented 4 years ago

Proposed changes allow for the following without busy loops:

  -- client
  local client = mqtt.client {
    connector = require("mqtt.luasocket-copas"),
    ...
  }

  -- client setup
  ...

  -- client thread
  copas.addthread(function()
    while true do
      client:_ioloop_iteration()
    end
  end)

  -- custom logic
  copas.addthread(function()
    while true do
      copas.sleep(1)
      print("TICK!")
    end
  end)

  copas.loop()
xHasKx commented 3 years ago

continue in pull request #27