also in handleClose

This commit is contained in:
Tanguy 2023-05-10 17:37:24 +02:00
parent a0ef79b127
commit d01393774e
No known key found for this signature in database
GPG Key ID: 7DD8EC6B6CE6C45E

View File

@ -264,6 +264,16 @@ proc handleClose*(
await sleepAsync(10.millis)
await ws.stream.closeWait()
if not isNil(ws.sendLoop):
ws.sendLoop.cancel()
# don't care about opcode,
# but we can only have a single
# `_` in 1.2
for (_, opcode, fut) in ws.sendQueue:
if not fut.finished:
fut.fail(WSClosedError.newException("Session got closed"))
ws.sendQueue.clear()
proc handleControl*(ws: WSSession, frame: Frame) {.async.} =
## Handle control frames
##