diff --git a/parameter.go b/parameter.go index f8176ba..2a566f4 100644 --- a/parameter.go +++ b/parameter.go @@ -10,7 +10,7 @@ type WsParameter struct { ReqHeaders map[string][]string Dialer *websocket.Dialer MessageHandleFunc func([]byte) error - ReSubscribeFunc func() error // 短线重连后触发,你可以重新订阅,因为有些订阅跟当前时间相关 + ReSubscribeFunc func(ws *WsConn) error // 短线重连后触发,你可以重新订阅,因为有些订阅跟当前时间相关 ErrorHandleFunc func(err error) AutoReconnect bool // 自动重连(默认: true) ReSubscribe bool // 自动重新订阅(默认: true) @@ -62,7 +62,7 @@ func WsMessageHandleFuncOption(f func([]byte) error) WsParameterOption { } } -func WsReSubscribeFuncOption(f func() error) WsParameterOption { +func WsReSubscribeFuncOption(f func(ws *WsConn) error) WsParameterOption { return func(p *WsParameter) { p.ReSubscribeFunc = f } diff --git a/websocket.go b/websocket.go index 2498843..f25c87d 100644 --- a/websocket.go +++ b/websocket.go @@ -83,7 +83,7 @@ func (ws *WsConn) reconnect() { } } if ws.ReSubscribeFunc != nil { - err = ws.ReSubscribeFunc() + err = ws.ReSubscribeFunc(ws) if err != nil { log.Printf("[ws] websocket re-subscribe fail, %s", err.Error()) }