fix messages with multiple empty frames (#61)
This commit is contained in:
parent
1188bf3c0b
commit
deb46fef31
|
@ -354,28 +354,26 @@ proc recv*(
|
||||||
trace "Setting binary flag"
|
trace "Setting binary flag"
|
||||||
|
|
||||||
let len = min(ws.frame.remainder.int, size - consumed)
|
let len = min(ws.frame.remainder.int, size - consumed)
|
||||||
if len <= 0:
|
if len > 0:
|
||||||
trace "Nothing left to read, breaking!"
|
trace "Reading bytes from frame stream", len
|
||||||
break
|
let read = await ws.stream.reader.readOnce(addr pbuffer[consumed], len)
|
||||||
|
if read <= 0:
|
||||||
|
trace "Didn't read any bytes, breaking"
|
||||||
|
break
|
||||||
|
|
||||||
trace "Reading bytes from frame stream", len
|
trace "Read data from frame", read
|
||||||
let read = await ws.stream.reader.readOnce(addr pbuffer[consumed], len)
|
|
||||||
if read <= 0:
|
|
||||||
trace "Didn't read any bytes, breaking"
|
|
||||||
break
|
|
||||||
|
|
||||||
if ws.frame.mask:
|
if ws.frame.mask:
|
||||||
trace "Unmasking frame"
|
trace "Unmasking frame"
|
||||||
# unmask data using offset
|
# unmask data using offset
|
||||||
mask(
|
mask(
|
||||||
pbuffer.toOpenArray(consumed, (consumed + read) - 1),
|
pbuffer.toOpenArray(consumed, (consumed + read) - 1),
|
||||||
ws.frame.maskKey,
|
ws.frame.maskKey,
|
||||||
ws.frame.consumed.int)
|
ws.frame.consumed.int)
|
||||||
|
|
||||||
consumed += read
|
consumed += read
|
||||||
ws.frame.consumed += read.uint64
|
ws.frame.consumed += read.uint64
|
||||||
|
|
||||||
trace "Read data from frame", read
|
|
||||||
# all has been consumed from the frame
|
# all has been consumed from the frame
|
||||||
# read the next frame
|
# read the next frame
|
||||||
if ws.frame.remainder <= 0:
|
if ws.frame.remainder <= 0:
|
||||||
|
|
Loading…
Reference in New Issue