fix: call onclose when conn closes

This commit is contained in:
minish 2025-12-19 01:37:20 -05:00
parent fa11551e26
commit eaa39ffc49
Signed by: min
SSH Key Fingerprint: SHA256:h4k7JNrfe1dzv1WE3oGVeAY9DPSZXIu3/j89+6DtHWE
3 changed files with 5 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import (
"log"
"time"
"github.com/shinosaki/websocket-client-go/websocket"
"git.min.rip/min/websocket-client-go/websocket"
)
const (

2
go.mod
View File

@ -1,4 +1,4 @@
module github.com/shinosaki/websocket-client-go
module git.min.rip/min/websocket-client-go
go 1.23.6

View File

@ -78,6 +78,9 @@ func (ws *WebSocketClient) Connect(
var payload []byte
if err := websocket.Message.Receive(ws.conn, &payload); err != nil {
// log.Println("receive error", err)
if ws.onClose != nil {
ws.onClose(ws, isReconnecting)
}
return
}
ws.onMessage(ws, payload)