Skip to content

Commit

Permalink
lan server: updated client notification (eventhandling)
Browse files Browse the repository at this point in the history
  • Loading branch information
dh1tw committed Nov 26, 2019
1 parent 5917cb9 commit 2642327
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions cmd/lan_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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{})
Expand Down Expand Up @@ -191,7 +197,6 @@ func lanServer(cmd *cobra.Command, args []string) {
return
}
}

}

func startMdnsServer(shutdown <-chan struct{}) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func webServer(cmd *cobra.Command, args []string) {
RotatorName: u.rotatorName, //MISSING
Heading: u.heading,
}
w.BroadcastToWsClients(ev)
w.Broadcast(ev)
}
}
}
Expand Down

0 comments on commit 2642327

Please sign in to comment.