dt1t and counter and refactoring using embedded interfaces
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2023-12-21 13:05:00 +01:00
parent 99d678b4b1
commit 8e6bea3f19
15 changed files with 276 additions and 174 deletions

View File

@ -1,29 +1,23 @@
package iot
import "log"
import "fmt"
import "udi/config"
import "udi/handlers/handler"
var idSeq int = 0
type IoTHandler struct {
id int
handler.CommonHandler
}
func NewIoTHandler() handler.Handler {
func New(id string, config config.HandlerConfigT) handler.Handler {
t := &IoTHandler {
id: idSeq,
}
idSeq += 1
t.Id = id
return t
}
func (self *IoTHandler) GetId() string {
return fmt.Sprintf("IoT%d", self.id)
}
func (self *IoTHandler) Handle(message handler.MessageT) {
log.Printf("Handler IoT %d processing %s -> %s", self.id, message.Topic, message.Payload)
log.Printf("Handler IoT %d processing %s -> %s", self.Id, message.Topic, message.Payload)
}