diff options
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r-- | src/rhctl/switch_control.go | 31 |
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 } } |