2015-03-09 13:09:13 +01:00
|
|
|
package main
|
|
|
|
|
2015-03-09 14:01:30 +01:00
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"html/template"
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
|
|
|
|
var geoJSONTmpl = template.Must(template.New("geojson").Parse(
|
|
|
|
`{ "type": "Feature",
|
|
|
|
"geometry": {
|
|
|
|
"type": "Point",
|
|
|
|
"coordinates": [{{.X}}, {{.Z}}]
|
|
|
|
},
|
|
|
|
"properties": {
|
|
|
|
"name": {{.Name || html }}
|
|
|
|
}
|
|
|
|
}`))
|
|
|
|
|
|
|
|
type player struct {
|
|
|
|
X float64
|
|
|
|
Y float64
|
|
|
|
Z float64
|
|
|
|
Name string
|
|
|
|
}
|
2015-03-09 13:09:13 +01:00
|
|
|
|
|
|
|
type players struct {
|
|
|
|
fifo string
|
2015-03-09 13:16:31 +01:00
|
|
|
wsf *websocketForwarder
|
2015-03-09 14:01:30 +01:00
|
|
|
pls []*player
|
2015-03-09 13:09:13 +01:00
|
|
|
}
|
|
|
|
|
2015-03-09 13:16:31 +01:00
|
|
|
func newPlayers(fifo string, wsf *websocketForwarder) *players {
|
|
|
|
return &players{fifo: fifo, wsf: wsf}
|
2015-03-09 13:09:13 +01:00
|
|
|
}
|
|
|
|
|
2015-03-09 14:01:30 +01:00
|
|
|
func (p *player) MarshalJSON() ([]byte, error) {
|
|
|
|
var buf bytes.Buffer
|
|
|
|
if err := geoJSONTmpl.Execute(&buf, p); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return buf.Bytes(), nil
|
|
|
|
}
|
|
|
|
|
2015-03-09 13:09:13 +01:00
|
|
|
func (ps *players) run() {
|
|
|
|
for {
|
|
|
|
// TODO: Implement me!
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ps *players) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
|
|
|
|
// TODO: Implement me!
|
|
|
|
}
|