sometimes recvLine returns "\r\n" when the peer disconnects (not documented). Handle that as a disconnect.

This commit is contained in:
Christian Ulrich 2020-07-21 10:17:36 +02:00
parent 41048dd8cd
commit 301ca6c81d
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 2 additions and 1 deletions

View File

@ -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