Merge pull request #9 from csucu/fix-relayAsyncEvents
Modified parsing of eventcode in relayAsyncEvents
This commit is contained in:
commit
a3771891b4
|
@ -271,11 +271,16 @@ 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 {
|
||||
return
|
||||
// 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:]
|
||||
|
|
Loading…
Reference in New Issue