dt1t and counter and refactoring using embedded interfaces
This commit is contained in:
@ -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)
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user