From a547fe88a42d1e0aebfc01d5d90dd21fc101fc2e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 25 Sep 2016 00:11:26 +0200 Subject: some more marshaller diff --git a/src/rhctl/audio_switch.go b/src/rhctl/audio_switch.go index a5c1a5c..f8c1cb1 100644 --- a/src/rhctl/audio_switch.go +++ b/src/rhctl/audio_switch.go @@ -34,8 +34,8 @@ const ( SwitchError ) -func (c SwitchResult) String() string { - switch c { +func (r SwitchResult) String() string { + switch r { case SwitchOK: return "OK" case SwitchError: @@ -44,6 +44,11 @@ func (c SwitchResult) String() string { return "unknown" } +func (r SwitchResult) MarshalText() (data []byte, err error) { + data = []byte(r.String()) + return +} + type SwitchResponse struct { Result SwitchResult Message string @@ -59,8 +64,8 @@ const ( SwitchSilence ) -func (c SwitchUpdateType) String() string { - switch c { +func (u SwitchUpdateType) String() string { + switch u { case SwitchAudio: return "audio" case SwitchGPI: @@ -75,6 +80,11 @@ func (c SwitchUpdateType) String() string { return "unknown" } +func (u SwitchUpdateType) MarshalText() (data []byte, err error) { + data = []byte(u.String()) + return +} + type SwitchUpdate struct { Type SwitchUpdateType Data string diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go index 2aca202..cc5f6bf 100644 --- a/src/rhctl/playout_server.go +++ b/src/rhctl/playout_server.go @@ -46,6 +46,11 @@ func (s ServerHealth) String() string { return "unknown" } +func (s ServerHealth) MarshalText() (data []byte, err error) { + data = []byte(s.String()) + return +} + type ServerState struct { Name string Health ServerHealth diff --git a/src/rhctl/switch_control.go b/src/rhctl/switch_control.go index 235fd95..200bae7 100644 --- a/src/rhctl/switch_control.go +++ b/src/rhctl/switch_control.go @@ -85,6 +85,11 @@ func (c CommandType) String() string { return "unknown" } +func (c CommandType) MarshalText() (data []byte, err error) { + data = []byte(c.String()) + return +} + type Command struct { Type CommandType Args []string diff --git a/web-static/socket.html b/web-static/socket.html index fc1b270..cf367e3 100644 --- a/web-static/socket.html +++ b/web-static/socket.html @@ -66,7 +66,7 @@ this.req = req this.sock = new WebSocket("wss://rdimport.helsinki.at/rhctl/socket"); this.sock_onmessage = function (event) { - $('#rawmsg').text(event.data); + $('#rawmsg').append(event.data + "\n\n"); } this.sock.onmessage = this.sock_onmessage.bind(this); -- cgit v0.10.2