File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ type Adaptor struct {
3232	cleanSession   bool 
3333	client         paho.Client 
3434	qos            int 
35+ 	optionsFn      func (* paho.ClientOptions )
3536}
3637
3738// NewAdaptor creates a new mqtt adaptor with specified host and client id 
@@ -109,9 +110,16 @@ func (a *Adaptor) ClientKey() string { return a.clientKey }
109110// SetClientKey sets the MQTT client SSL key file 
110111func  (a  * Adaptor ) SetClientKey (val  string ) { a .clientKey  =  val  }
111112
113+ // SetOptionsFn sets the MQTT client extended options 
114+ func  (a  * Adaptor ) SetOptionsFn (fn  func (* paho.ClientOptions )) { a .optionsFn  =  fn  }
115+ 
112116// Connect returns true if connection to mqtt is established 
113117func  (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 )
115123	if  token  :=  a .client .Connect (); token .Wait () &&  token .Error () !=  nil  {
116124		return  token .Error ()
117125	}
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments