Skip to content

Commit 48a35d5

Browse files
committed
Add isErrored() function so we can tell if the context / connection
is in the "errored" state, as may occur if the initial TCP connection fails.
1 parent a704fa9 commit 48a35d5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

nmqtt.nim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,6 +1216,11 @@ proc unsubscribe*(ctx: MqttCtx, topic: string): Future[void] =
12161216
ctx.workQueue[msgId] = Work(wk: SubWork, msgId: msgId, topic: topic, typ: Unsubscribe)
12171217
result = ctx.work()
12181218

1219+
proc isErrored*(ctx: MqttCtx): bool =
1220+
## Returns true, if the context is in an error state
1221+
if ctx.state == Error:
1222+
result = true
1223+
12191224
proc isConnected*(ctx: MqttCtx): bool =
12201225
## Returns true, if the client is connected to the broker.
12211226
if ctx.state == Connected:

0 commit comments

Comments
 (0)