Added 'websocket' branch. Added mechanism to forward the coords of the updated base tiles.

This commit is contained in:
Sascha L. Teichmann 2015-03-02 13:10:30 +01:00
parent 003d8cc785
commit 3e0e909a69
2 changed files with 23 additions and 3 deletions

View File

@ -78,6 +78,9 @@ func main() {
subBaseLine := newSubBaseLine(mapDir) subBaseLine := newSubBaseLine(mapDir)
router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine) router.Path("/map/{z:[0-9]+}/{x:[0-9]+}/{y:[0-9]+}.png").Handler(subBaseLine)
// TODO: Implement me!
var btu baseTilesUpdates
if redisHost != "" { if redisHost != "" {
var colors *common.Colors var colors *common.Colors
var err error var err error
@ -92,7 +95,13 @@ func main() {
} }
tu := newTileUpdater( tu := newTileUpdater(
mapDir, redisAddress, allowedUpdateIps, colors, transparent, workers) mapDir,
redisAddress,
allowedUpdateIps,
colors,
transparent,
workers,
btu)
go tu.doUpdates() go tu.doUpdates()
router.Path("/update").Methods("POST").Handler(tu) router.Path("/update").Methods("POST").Handler(tu)
} }

View File

@ -24,8 +24,13 @@ import (
"bitbucket.org/s_l_teichmann/mtsatellite/common" "bitbucket.org/s_l_teichmann/mtsatellite/common"
) )
type baseTilesUpdates interface {
BaseTilesUpdated(map[xz]bool)
}
type tileUpdater struct { type tileUpdater struct {
changes map[xz]bool changes map[xz]bool
btu baseTilesUpdates
mapDir string mapDir string
redisAddress string redisAddress string
ips []net.IP ips []net.IP
@ -67,9 +72,11 @@ func newTileUpdater(
ips []net.IP, ips []net.IP,
colors *common.Colors, colors *common.Colors,
transparent bool, transparent bool,
workers int) *tileUpdater { workers int,
btu baseTilesUpdates) *tileUpdater {
tu := tileUpdater{ tu := tileUpdater{
btu: btu,
mapDir: mapDir, mapDir: mapDir,
redisAddress: redisAddress, redisAddress: redisAddress,
ips: ips, ips: ips,
@ -166,7 +173,7 @@ func (tu *tileUpdater) doUpdates() {
parentJobs := make(map[xz]uint16) parentJobs := make(map[xz]uint16)
for c, _ := range changes { for c := range changes {
//log.Printf("job: %+v", c) //log.Printf("job: %+v", c)
jobs <- c jobs <- c
pxz := c.parent() pxz := c.parent()
@ -191,6 +198,10 @@ func (tu *tileUpdater) doUpdates() {
done.Wait() done.Wait()
parentJobs = ppJobs parentJobs = ppJobs
} }
if tu.btu != nil {
tu.btu.BaseTilesUpdated(changes)
}
} }
} }