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 peerId = ""
|
||||
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:
|
||||
removeClient(clients, peerId)
|
||||
break
|
||||
|
|
Loading…
Reference in New Issue