summaryrefslogtreecommitdiff
path: root/src/rhctl/telnet.go
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-30 00:06:52 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-30 00:06:52 (GMT)
commita8345a1ac7105a4393ab189e45c5ef0aead7577e (patch)
tree8b9226a9c73970b9ca30c6c004bfe4994f584c06 /src/rhctl/telnet.go
parent4ee99882db8019a6b49fd22f42b23fc00d2644d6 (diff)
add support for listening to status messages
Diffstat (limited to 'src/rhctl/telnet.go')
-rw-r--r--src/rhctl/telnet.go44
1 files changed, 41 insertions, 3 deletions
diff --git a/src/rhctl/telnet.go b/src/rhctl/telnet.go
index 8d73846..a07a820 100644
--- a/src/rhctl/telnet.go
+++ b/src/rhctl/telnet.go
@@ -22,6 +22,7 @@
package main
import (
+ "github.com/olebedev/emitter"
"github.com/spreadspace/telgo"
)
@@ -35,9 +36,44 @@ func telnetStatus(c *telgo.Client, args []string, ctrl *SwitchControl) bool {
return false
}
+func telnetListener(c *telgo.Client, ch <-chan emitter.Event) {
+ rhdl.Println("started telnetListener goroutine")
+ for {
+ event, ok := <-ch
+ if !ok {
+ return
+ }
+ c.Sayln("got event: %+v", event) // we need a way to find out that the client has stopped working
+ }
+ rhdl.Println("stopped telnetListener goroutine")
+}
+
func telnetListen(c *telgo.Client, args []string, ctrl *SwitchControl) bool {
- ctrl.Commands <- &Command{Type: CmdListen}
- // TODO: implement this
+ var ch <-chan emitter.Event
+ if len(args) <= 1 {
+ ch = ctrl.Updates.On("*")
+ } else {
+ switch args[1] {
+ case "status":
+ ch = ctrl.Updates.On("status")
+ case "server":
+ ch = ctrl.Updates.On("server:status")
+ case "audio":
+ fallthrough
+ case "gpi":
+ fallthrough
+ case "oc":
+ fallthrough
+ case "relay":
+ fallthrough
+ case "silence":
+ ch = ctrl.Updates.On("switch:" + args[1])
+ default:
+ c.Sayln("unknown message type")
+ return false
+ }
+ }
+ go telnetListener(c, ch)
return false
}
@@ -72,7 +108,9 @@ func telnetHelp(c *telgo.Client, args []string) bool {
case "listen":
c.Sayln("usage: listen [ <type> ]")
c.Sayln(" subscribe to messages of type <type>. The following types are allowed:")
- c.Sayln(" - status audio input/output mapping changes")
+ c.Sayln(" - status overall status changes")
+ c.Sayln(" - server status/health of the playout server")
+ c.Sayln(" - audio audio input/output mapping changes")
c.Sayln(" - gpi general purpose input status messages")
c.Sayln(" - oc open-collector status messages")
c.Sayln(" - relay relay status messages")