diff options
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r-- | src/rhctl/switch_control.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index b48ac07..82faec8 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -21,11 +21,14 @@ package main +import ( + "github.com/olebedev/emitter" +) + type CommandType uint8 const ( CmdStatus CommandType = iota - CmdListen CmdServer CmdSwitch ) @@ -34,8 +37,6 @@ func (c CommandType) String() string { switch c { case CmdStatus: return "status" - case CmdListen: - return "listen" case CmdServer: return "server" case CmdSwitch: @@ -52,6 +53,7 @@ type Command struct { type SwitchControl struct { sw *AudioSwitch servers []*PlayoutServer + Updates *emitter.Emitter Commands chan *Command } @@ -59,7 +61,6 @@ func (ctrl *SwitchControl) handleCommand(cmd *Command) { rhdl.Printf("Telnet: got command: %+v", cmd) switch cmd.Type { case CmdStatus: - case CmdListen: case CmdServer: case CmdSwitch: } @@ -87,9 +88,10 @@ func (ctrl *SwitchControl) Run() { for _, srv := range ctrl.servers { srv.SwitchUpdates <- update } - // TODO: send out to all clients who are interested in this + ctrl.Updates.Emit("switch:"+update.Type.String(), update) case status := <-serverUpdates: rhdl.Printf("got server status update: %+v", status) + ctrl.Updates.Emit("server:status", status) // TODO: recalculate overall status and send out commands to switch case cmd := <-ctrl.Commands: ctrl.handleCommand(cmd) @@ -101,6 +103,7 @@ func SwitchControlInit(conf *Config, sw *AudioSwitch, servers []*PlayoutServer) ctrl = &SwitchControl{} ctrl.sw = sw ctrl.servers = servers + ctrl.Updates = emitter.New(32) ctrl.Commands = make(chan *Command, 8) return } |