sometimes recvLine returns "\r\n" when the peer disconnects (not documented). Handle that as a disconnect.
This commit is contained in:
parent
41048dd8cd
commit
301ca6c81d
|
@ -34,7 +34,8 @@ proc processClient(client: AsyncSocket, clients: TableRef[string, Client]) {.asy
|
||||||
var id = ""
|
var id = ""
|
||||||
var peerId = ""
|
var peerId = ""
|
||||||
while true:
|
while true:
|
||||||
let line = await client.recvLine(maxLength = 400)
|
var line = await client.recvLine(maxLength = 400)
|
||||||
|
line = line.strip(leading = false, trailing = true, chars = {'\r', '\n'})
|
||||||
if line.len == 0:
|
if line.len == 0:
|
||||||
removeClient(clients, peerId)
|
removeClient(clients, peerId)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue