wifictld-analyzer/controller/main.go

38 lines
679 B
Go

package controller
import (
"net"
"time"
"github.com/bdlm/log"
"dev.sum7.eu/genofire/wifictld-analyzer/data"
"dev.sum7.eu/genofire/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))
}
}