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

View File

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