From ba5dbc955de46ce3ccc5f89f6a6bc85e77037718 Mon Sep 17 00:00:00 2001 From: csucu Date: Sun, 22 Jul 2018 17:15:54 +0100 Subject: [PATCH 1/2] Modified parsing of eventcode in relayAsyncEvents --- control/cmd_event.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/control/cmd_event.go b/control/cmd_event.go index 2500b0b..1e054e3 100644 --- a/control/cmd_event.go +++ b/control/cmd_event.go @@ -271,11 +271,17 @@ func (c *Conn) relayAsyncEvents(resp *Response) { var dataArray []string if len(resp.Data) == 1 { // If there is a single line of data, first line of it is the code, rest of the first line is data - firstNewline := strings.Index(resp.Data[0], "\r\n") - if firstNewline == -1 { + // Find the index which specfies the char after the event code, either space or newline + index := strings.Index(resp.Data[0], " ") + if index == -1 { + index = strings.Index(resp.Data[0], "\r\n") + } + + if index == -1 { return } - code, data = resp.Data[0][:firstNewline], resp.Data[0][firstNewline+2:] + + code, data = resp.Data[0][:index], resp.Data[0][index+2:] } else if len(resp.Data) > 0 { // If there are multiple lines, the entire first line is the code code, dataArray = resp.Data[0], resp.Data[1:] From 4aedc493a335b3029cad478d3ded5e3764daa5c4 Mon Sep 17 00:00:00 2001 From: csucu Date: Sun, 22 Jul 2018 17:32:29 +0100 Subject: [PATCH 2/2] Moved -1 check --- control/cmd_event.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/control/cmd_event.go b/control/cmd_event.go index 1e054e3..3c9856f 100644 --- a/control/cmd_event.go +++ b/control/cmd_event.go @@ -275,10 +275,9 @@ func (c *Conn) relayAsyncEvents(resp *Response) { index := strings.Index(resp.Data[0], " ") if index == -1 { index = strings.Index(resp.Data[0], "\r\n") - } - - if index == -1 { - return + if index == -1 { + return + } } code, data = resp.Data[0][:index], resp.Data[0][index+2:]