File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ type Adaptor struct {
32
32
cleanSession bool
33
33
client paho.Client
34
34
qos int
35
+ optionsFn func (* paho.ClientOptions )
35
36
}
36
37
37
38
// NewAdaptor creates a new mqtt adaptor with specified host and client id
@@ -109,9 +110,16 @@ func (a *Adaptor) ClientKey() string { return a.clientKey }
109
110
// SetClientKey sets the MQTT client SSL key file
110
111
func (a * Adaptor ) SetClientKey (val string ) { a .clientKey = val }
111
112
113
+ // SetOptionsFn sets the MQTT client extended options
114
+ func (a * Adaptor ) SetOptionsFn (fn func (* paho.ClientOptions )) { a .optionsFn = fn }
115
+
112
116
// Connect returns true if connection to mqtt is established
113
117
func (a * Adaptor ) Connect () error {
114
- a .client = paho .NewClient (a .createClientOptions ())
118
+ opts := a .createClientOptions ()
119
+ if a .optionsFn != nil {
120
+ a .optionsFn (opts )
121
+ }
122
+ a .client = paho .NewClient (opts )
115
123
if token := a .client .Connect (); token .Wait () && token .Error () != nil {
116
124
return token .Error ()
117
125
}
You can’t perform that action at this time.
0 commit comments