summaryrefslogtreecommitdiff
path: root/src/rhctl/switch_control.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-27 20:14:59 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-27 20:14:59 (GMT)
commit61f48b85e0c0301b1c5384c09c822bc5e2265a4f (patch)
treefba14c1d2a00340dfe9635bf50f6f257894b742d /src/rhctl/switch_control.go
parent3b9dc5639b9b26bb5a8e4324de47f77a00e0e86a (diff)
receiving of updates from switch as well from servers works now
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r--src/rhctl/switch_control.go31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index de5bf6d..40dd788 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -21,20 +21,39 @@
package main
-import (
- "time"
-)
-
type SwitchControl struct {
sw *AudioSwitch
servers []*PlayoutServer
}
-func (sw *SwitchControl) Run() {
+func handleServer(in <-chan ServerStatus, out chan<- ServerStatus) {
+ for {
+ update := <-in
+ out <- update
+ }
+}
+
+func (ctrl *SwitchControl) Run() {
rhdl.Printf("SwitchCTRL: handler running...")
+ serverUpdates := make(chan ServerStatus, 8)
+ for _, srv := range ctrl.servers {
+ go handleServer(srv.Updates, serverUpdates)
+ }
+
for {
- time.Sleep(time.Second)
+ select {
+ case update := <-ctrl.sw.Updates:
+ rhdl.Printf("got update from switch: %+v", update)
+ for _, srv := range ctrl.servers {
+ srv.SwitchUpdates <- update
+ }
+ // TODO: send out to all clients who are interested in this
+ case status := <-serverUpdates:
+ rhdl.Printf("got server status update: %+v", status)
+ // TODO: recalculate overall status and send out commands to switch
+ }
+ // TODO: add handler for requests from control clients
}
}