Skip to content

Commit ea9476a

Browse files
authored
hasError - return true if error connection (#63)
1 parent eabb345 commit ea9476a

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎nmqtt.nim‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,16 +1308,19 @@ proc unsubscribe*(ctx: MqttCtx, topic: string): Future[void] =
13081308
ctx.workQueue[msgId] = Work(wk: SubWork, msgId: msgId, topic: topic, typ: Unsubscribe)
13091309
result = ctx.work()
13101310

1311-
proc isConnected*(ctx: MqttCtx): bool =
1311+
proc isConnected*(ctx: MqttCtx): bool {.inline.} =
13121312
## Returns true, if the client is connected to the broker.
1313-
if ctx.state == Connected:
1314-
result = true
1313+
ctx.state == Connected
13151314

1316-
proc msgQueue*(ctx: MqttCtx): int =
1315+
proc hasError*(ctx: MqttCtx): bool {.inline.} =
1316+
## Returns true, if the context is in an error state.
1317+
ctx.state == Error
1318+
1319+
proc msgQueue*(ctx: MqttCtx): int {.inline.} =
13171320
## Returns the number of unfinished packages, which still are in the work queue.
13181321
## This includes all publish and subscribe packages, which has not been fully
13191322
## send, acknowledged or completed.
13201323
##
13211324
## You can use this to ensure, that all your of messages are sent, before
13221325
## exiting your program.
1323-
result = ctx.workQueue.len()
1326+
ctx.workQueue.len()

0 commit comments

Comments
 (0)