Skip to content

Commit a23c834

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 2bc6c76 commit a23c834

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
@@ -1209,6 +1209,11 @@ proc unsubscribe*(ctx: MqttCtx, topic: string): Future[void] =
12091209
ctx.workQueue[msgId] = Work(wk: SubWork, msgId: msgId, topic: topic, typ: Unsubscribe)
12101210
result = ctx.work()
12111211

1212+
proc isErrored*(ctx: MqttCtx): bool =
1213+
## Returns true, if the context is in an error state
1214+
if ctx.state == Error:
1215+
result = true
1216+
12121217
proc isConnected*(ctx: MqttCtx): bool =
12131218
## Returns true, if the client is connected to the broker.
12141219
if ctx.state == Connected:

0 commit comments

Comments
 (0)