Return io.EOF on websocket connection closure
This commit is contained in:
parent
cfb1de044e
commit
0fa07f5f9a
8
conn.go
8
conn.go
@ -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))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user