wifictld-analyzer/controller/main.go

38 lines
672 B
Go

package controller
import (
"net"
"time"
log "github.com/sirupsen/logrus"
"dev.sum7.eu/wifictld/analyzer/data"
"dev.sum7.eu/wifictld/analyzer/database"
)
type Controller struct {
SendTo func(addr *net.UDPAddr, msg *data.SocketMSG)
Send func(msg *data.SocketMSG)
db *database.DB
ticker *time.Ticker
}
func NewController(db *database.DB) *Controller {
ctl := &Controller{
ticker: time.NewTicker(time.Minute),
db: db,
}
go ctl.Repeated()
return ctl
}
func (c *Controller) Close() {
c.ticker.Stop()
}
func (c *Controller) Repeated() {
for range c.ticker.C {
log.Debugf("lerned: %d APs, %d Clients", len(c.db.APs), len(c.db.Clients))
}
}