wifictld-analyzer/controller/main.go

38 lines
672 B
Go
Raw Normal View History

2018-06-03 20:37:52 +02:00
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 {
2018-07-16 13:00:37 +02:00
SendTo func(addr *net.UDPAddr, msg *data.SocketMSG)
Send func(msg *data.SocketMSG)
db *database.DB
ticker *time.Ticker
2018-06-03 20:37:52 +02:00
}
2018-07-10 21:40:38 +02:00
func NewController(db *database.DB) *Controller {
2018-06-03 20:37:52 +02:00
ctl := &Controller{
2018-07-10 21:40:38 +02:00
ticker: time.NewTicker(time.Minute),
db: db,
2018-06-03 20:37:52 +02:00
}
go ctl.Repeated()
return ctl
}
func (c *Controller) Close() {
c.ticker.Stop()
}
func (c *Controller) Repeated() {
for range c.ticker.C {
2018-07-16 13:00:37 +02:00
log.Debugf("lerned: %d APs, %d Clients", len(c.db.APs), len(c.db.Clients))
2018-06-03 20:37:52 +02:00
}
}