fix: adding SafeWebSocketClient parameter
This commit is contained in:
@@ -71,7 +71,7 @@ type SafeWebsocketClientBuilder struct {
|
||||
rawQuery *string
|
||||
useTLS *bool
|
||||
channelSize *int64
|
||||
authenticateFn func() error
|
||||
authenticateFn func(*SafeWebsocketClient) error
|
||||
}
|
||||
|
||||
func NewSafeWebsocketClientBuilder() *SafeWebsocketClientBuilder {
|
||||
@@ -93,7 +93,7 @@ func (b *SafeWebsocketClientBuilder) UseTLS(useTLS bool) *SafeWebsocketClientBui
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *SafeWebsocketClientBuilder) AuthenticateFn(authenticateFn func() error) *SafeWebsocketClientBuilder {
|
||||
func (b *SafeWebsocketClientBuilder) AuthenticateFn(authenticateFn func(*SafeWebsocketClient) error) *SafeWebsocketClientBuilder {
|
||||
b.authenticateFn = authenticateFn
|
||||
return b
|
||||
}
|
||||
@@ -170,7 +170,7 @@ type SafeWebsocketClient struct {
|
||||
reconnectChans []chan struct{}
|
||||
isConnected bool
|
||||
doneMap *SafeMap[string, chan struct{}]
|
||||
authenticateFn func() error
|
||||
authenticateFn func(*SafeWebsocketClient) error
|
||||
}
|
||||
|
||||
func (wsClient *SafeWebsocketClient) connect() error {
|
||||
@@ -218,13 +218,12 @@ func (wsClient *SafeWebsocketClient) connect() error {
|
||||
wsClient.isConnected = true
|
||||
|
||||
if wsClient.authenticateFn != nil {
|
||||
if err := wsClient.authenticateFn(); err != nil {
|
||||
if err := wsClient.authenticateFn(wsClient); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
wsClient.mu.WriteHandler(func() error {
|
||||
|
||||
pingCtx, pingCancel := context.WithCancel(context.Background())
|
||||
go wsClient.startPingTicker(pingCtx)
|
||||
wsClient.cancelFuncs = append(wsClient.cancelFuncs, pingCancel)
|
||||
|
||||
Reference in New Issue
Block a user