Add mySituation uibroadcast.

pull/516/head
Christopher Young 2016-10-24 15:38:05 -04:00
rodzic 504d97ec7a
commit a949bda34f
2 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -36,6 +36,9 @@ type SettingMessage struct {
var weatherUpdate *uibroadcaster
var trafficUpdate *uibroadcaster
// Situation updates channel.
var situationUpdate *uibroadcaster
/*
The /weather websocket starts off by sending the current buffer of weather messages, then sends updates as they are received.
*/
@ -511,6 +514,7 @@ func viewLogs(w http.ResponseWriter, r *http.Request) {
func managementInterface() {
weatherUpdate = NewUIBroadcaster()
trafficUpdate = NewUIBroadcaster()
situationUpdate = NewUIBroadcaster()
http.HandleFunc("/", defaultServer)
http.Handle("/logs/", http.StripPrefix("/logs/", http.FileServer(http.Dir("/var/log"))))

Wyświetl plik

@ -456,6 +456,15 @@ func calculateNACp(accuracy float32) uint8 {
return ret
}
/*
registerSituationUpdate().
Called whenever there is a change in mySituation.
*/
func registerSituationUpdate() {
logSituation()
situationUpdate.SendJSON(mySituation)
}
/*
processNMEALine parses NMEA-0183 formatted strings against several message types.
@ -472,7 +481,7 @@ func processNMEALine(l string) (sentenceUsed bool) {
defer func() {
if sentenceUsed || globalSettings.DEBUG {
logSituation()
registerSituationUpdate()
}
mySituation.mu_GPS.Unlock()
}()