kopia lustrzana https://github.com/cyoung/stratux
Skip traffic targets on websocket with no valid position.
rodzic
aafcd4892c
commit
2661c86560
|
@ -43,6 +43,9 @@ func handleWeatherWS(conn *websocket.Conn) {
|
||||||
func handleTrafficWS(conn *websocket.Conn) {
|
func handleTrafficWS(conn *websocket.Conn) {
|
||||||
trafficMutex.Lock()
|
trafficMutex.Lock()
|
||||||
for _, traf := range traffic {
|
for _, traf := range traffic {
|
||||||
|
if !traf.Position_valid { // Don't send unless a valid position exists.
|
||||||
|
continue
|
||||||
|
}
|
||||||
trafficJSON, _ := json.Marshal(&traf)
|
trafficJSON, _ := json.Marshal(&traf)
|
||||||
conn.Write(trafficJSON)
|
conn.Write(trafficJSON)
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,9 @@ func sendTrafficUpdates() {
|
||||||
|
|
||||||
// Send update to attached client.
|
// Send update to attached client.
|
||||||
func registerTrafficUpdate(ti TrafficInfo) {
|
func registerTrafficUpdate(ti TrafficInfo) {
|
||||||
trafficUpdate <- ti
|
if ti.Position_valid { // Don't send unless a valid position exists.
|
||||||
|
trafficUpdate <- ti
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeTrafficReport(ti TrafficInfo) {
|
func makeTrafficReport(ti TrafficInfo) {
|
||||||
|
|
Ładowanie…
Reference in New Issue