feat(protocol): allow override of dial func
This commit is contained in:
@ -2,6 +2,7 @@ package v2
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/logger"
|
||||
@ -17,6 +18,10 @@ type Operations struct {
|
||||
client *socketio.Client
|
||||
mutex sync.RWMutex
|
||||
logger logger.Logger
|
||||
dial protocol.DialFunc
|
||||
|
||||
getClientOnce sync.Once
|
||||
httpClient *http.Client
|
||||
}
|
||||
|
||||
// Reboot implements protocol.Operations.
|
||||
@ -161,12 +166,12 @@ func (o *Operations) Connect(ctx context.Context) error {
|
||||
o.client.Close()
|
||||
}
|
||||
|
||||
endpoint, err := socketio.EndpointFromHAddr(o.addr)
|
||||
endpoint, err := socketio.EndpointFromAddr(o.addr)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
client := socketio.NewClient(endpoint)
|
||||
client := socketio.NewClient(endpoint, socketio.WithDialFunc(socketio.DialFunc(o.dial)))
|
||||
|
||||
if err := client.Connect(); err != nil {
|
||||
return errors.WithStack(err)
|
||||
|
Reference in New Issue
Block a user