mirror of
https://github.com/jwetzell/showbridge-go.git
synced 2026-04-27 05:15:47 +00:00
move router to module New func
This commit is contained in:
@@ -21,7 +21,7 @@ type MQTTClient struct {
|
||||
func init() {
|
||||
RegisterModule(ModuleRegistration{
|
||||
Type: "net.mqtt.client",
|
||||
New: func(config config.ModuleConfig) (Module, error) {
|
||||
New: func(config config.ModuleConfig, router *Router) (Module, error) {
|
||||
params := config.Params
|
||||
broker, ok := params["broker"]
|
||||
|
||||
@@ -59,7 +59,7 @@ func init() {
|
||||
return nil, fmt.Errorf("net.mqtt.client clientId must be string")
|
||||
}
|
||||
|
||||
return &MQTTClient{config: config, Broker: brokerString, Topic: topicString, ClientID: clientIdString}, nil
|
||||
return &MQTTClient{config: config, Broker: brokerString, Topic: topicString, ClientID: clientIdString, router: router}, nil
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -72,10 +72,6 @@ func (mc *MQTTClient) Type() string {
|
||||
return mc.config.Type
|
||||
}
|
||||
|
||||
func (mc *MQTTClient) RegisterRouter(router *Router) {
|
||||
mc.router = router
|
||||
}
|
||||
|
||||
func (mc *MQTTClient) Run() error {
|
||||
opts := mqtt.NewClientOptions()
|
||||
opts.AddBroker(mc.Broker)
|
||||
|
||||
Reference in New Issue
Block a user