Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix of small typos #575

Merged
merged 2 commits into from Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion client.go
Expand Up @@ -393,7 +393,7 @@ func (c *client) attemptConnection() (net.Conn, byte, bool, error) {
tlsCfg = c.options.OnConnectAttempt(broker, c.options.TLSConfig)
}
// Start by opening the network connection (tcp, tls, ws) etc
if c.options.CustomOpenConnectionFn != nil{
if c.options.CustomOpenConnectionFn != nil {
conn, err = c.options.CustomOpenConnectionFn(broker, c.options)
} else {
conn, err = openConnection(broker, tlsCfg, c.options.ConnectTimeout, c.options.HTTPHeaders, c.options.WebsocketOptions, c.options.Dialer)
Expand Down
4 changes: 2 additions & 2 deletions client_test.go
Expand Up @@ -27,7 +27,7 @@ import (
)

func TestCustomConnectionFunction(t *testing.T) {
// Set netpipe to emu
// Set netpipe to emulate a connection of a different type
netClient, netServer := net.Pipe()
defer netClient.Close()
defer netServer.Close()
Expand Down Expand Up @@ -59,6 +59,6 @@ func TestCustomConnectionFunction(t *testing.T) {

// Analyze first message sent by client and received by the server
if len(firstMessage) <= 0 || !strings.Contains(firstMessage, "MQTT") {
t.Error("no message recieved on connect")
t.Error("no message received on connect")
}
}
8 changes: 4 additions & 4 deletions options.go
Expand Up @@ -437,12 +437,12 @@ func (o *ClientOptions) SetDialer(dialer *net.Dialer) *ClientOptions {
return o
}

// SetCustomOpenConectionFn replaces the inbuilt function that establishes a network connection with a custom function.
// SetCustomOpenConnectionFn replaces the inbuilt function that establishes a network connection with a custom function.
// The passed in function should return an open `net.Conn` or an error (see the existing openConnection function for an example)
// It enables custom networking types in addition to the defaults (tcp, tls, websockets...)
func (o *ClientOptions) SetCustomOpenConectionFn(customOpenConnectionfn OpenConnectionFunc) *ClientOptions {
if customOpenConnectionfn != nil {
o.CustomOpenConnectionFn = customOpenConnectionfn
func (o *ClientOptions) SetCustomOpenConnectionFn(customOpenConnectionFn OpenConnectionFunc) *ClientOptions {
if customOpenConnectionFn != nil {
o.CustomOpenConnectionFn = customOpenConnectionFn
}
return o
}
2 changes: 1 addition & 1 deletion options_test.go
Expand Up @@ -32,7 +32,7 @@ func TestSetCustomConnectionOptions(t *testing.T) {
return nil, fmt.Errorf("not implemented open connection func")
}
options := &ClientOptions{}
options = options.SetCustomOpenConectionFn(customConnectionFunc)
options = options.SetCustomOpenConnectionFn(customConnectionFunc)
if options.CustomOpenConnectionFn == nil {
t.Error("custom open connection function cannot be set")
}
Expand Down