Return io.EOF on websocket connection closure

This commit is contained in:
Simon Ser 2020-06-29 10:24:41 +02:00
parent cfb1de044e
commit 0fa07f5f9a
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@ package soju
import (
"context"
"fmt"
"io"
"net"
"sync"
"time"
@ -47,7 +48,12 @@ func (wic websocketIRCConn) ReadMessage() (*irc.Message, error) {
}
_, b, err := wic.conn.Read(ctx)
if err != nil {
return nil, err
switch websocket.CloseStatus(err) {
case websocket.StatusNormalClosure, websocket.StatusGoingAway:
return nil, io.EOF
default:
return nil, err
}
}
return irc.ParseMessage(string(b))
}