Skip to content

Commit

Permalink
Merge pull request #575 from GilGil1/master
Browse files Browse the repository at this point in the history
Fix of small typos from PR #574
  • Loading branch information
MattBrittan authored Dec 23, 2021
2 parents 6f41a8c + 0d8179f commit 44f71c7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 44f71c7

Please sign in to comment.