From 2642327c0f46a5f0e3b6ac8f8bc3ddd7d23aacb8 Mon Sep 17 00:00:00 2001 From: "Tobias Wellnitz, DH1TW" Date: Tue, 26 Nov 2019 23:59:36 +0100 Subject: [PATCH] lan server: updated client notification (eventhandling) --- cmd/lan_server.go | 13 +++++++++---- cmd/webserver.go | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cmd/lan_server.go b/cmd/lan_server.go index 512f314..b57f0dd 100644 --- a/cmd/lan_server.go +++ b/cmd/lan_server.go @@ -10,12 +10,13 @@ import ( "strings" "time" + // _ "net/http/pprof" + "github.com/dh1tw/remoteRotator/hub" "github.com/dh1tw/remoteRotator/rotator" "github.com/micro/mdns" "github.com/spf13/cobra" "github.com/spf13/viper" - // _ "net/http/pprof" ) var lanServerCmd = &cobra.Command{ @@ -123,10 +124,15 @@ func lanServer(cmd *cobra.Command, args []string) { // log.Println(http.ListenAndServe("0.0.0.0:6060", http.DefaultServeMux)) // }() - bcast := make(chan rotator.Heading, 10) + bcast := make(chan hub.Event, 10) var rEventHandler = func(r rotator.Rotator, heading rotator.Heading) { - bcast <- heading + e := hub.Event{ + Name: hub.UpdateHeading, + RotatorName: r.Name(), + Heading: heading, + } + bcast <- e } rotatorError := make(chan struct{}) @@ -191,7 +197,6 @@ func lanServer(cmd *cobra.Command, args []string) { return } } - } func startMdnsServer(shutdown <-chan struct{}) error { diff --git a/cmd/webserver.go b/cmd/webserver.go index 35f44ee..743812f 100644 --- a/cmd/webserver.go +++ b/cmd/webserver.go @@ -204,7 +204,7 @@ func webServer(cmd *cobra.Command, args []string) { RotatorName: u.rotatorName, //MISSING Heading: u.heading, } - w.BroadcastToWsClients(ev) + w.Broadcast(ev) } } }