summaryrefslogtreecommitdiff
path: root/src/rhctl/switch_control.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-29 22:04:00 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-29 22:04:00 (GMT)
commit4ee99882db8019a6b49fd22f42b23fc00d2644d6 (patch)
tree80186d65e9121486ce089feddadd48840d642def /src/rhctl/switch_control.go
parent59f010d9d418992e30fc9c798019a76b9d3df07b (diff)
basic telnet commands
Diffstat (limited to 'src/rhctl/switch_control.go')
-rw-r--r--src/rhctl/switch_control.go47
1 files changed, 44 insertions, 3 deletions
diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go
index 40dd788..b48ac07 100644
--- a/src/rhctl/switch_control.go
+++ b/src/rhctl/switch_control.go
@@ -21,9 +21,48 @@
package main
+type CommandType uint8
+
+const (
+ CmdStatus CommandType = iota
+ CmdListen
+ CmdServer
+ CmdSwitch
+)
+
+func (c CommandType) String() string {
+ switch c {
+ case CmdStatus:
+ return "status"
+ case CmdListen:
+ return "listen"
+ case CmdServer:
+ return "server"
+ case CmdSwitch:
+ return "switch"
+ }
+ return "unknown"
+}
+
+type Command struct {
+ Type CommandType
+ args []string
+}
+
type SwitchControl struct {
- sw *AudioSwitch
- servers []*PlayoutServer
+ sw *AudioSwitch
+ servers []*PlayoutServer
+ Commands chan *Command
+}
+
+func (ctrl *SwitchControl) handleCommand(cmd *Command) {
+ rhdl.Printf("Telnet: got command: %+v", cmd)
+ switch cmd.Type {
+ case CmdStatus:
+ case CmdListen:
+ case CmdServer:
+ case CmdSwitch:
+ }
}
func handleServer(in <-chan ServerStatus, out chan<- ServerStatus) {
@@ -52,8 +91,9 @@ func (ctrl *SwitchControl) Run() {
case status := <-serverUpdates:
rhdl.Printf("got server status update: %+v", status)
// TODO: recalculate overall status and send out commands to switch
+ case cmd := <-ctrl.Commands:
+ ctrl.handleCommand(cmd)
}
- // TODO: add handler for requests from control clients
}
}
@@ -61,5 +101,6 @@ func SwitchControlInit(conf *Config, sw *AudioSwitch, servers []*PlayoutServer)
ctrl = &SwitchControl{}
ctrl.sw = sw
ctrl.servers = servers
+ ctrl.Commands = make(chan *Command, 8)
return
}