zevv / nmqtt

Native Nim MQTT client library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Let user define `keep-alive` time

ThomasTJdev opened this issue · comments

Currently the pings run 1/sec. Let the user define the keep-alive time based its current signal strength or gut-feeling. The maximum keep alive is 18h 12min 15 sec.

proc runPing(ctx: MqttCtx) {.async.} =
  while true:
    await sleepAsync 1000
    let ok = await ctx.sendPingReq()
    if not ok:
      break
    await ctx.work()