Merge pull request #50 from AzuraMeta/patch-1

Fixed WORK_FAIL needing 2 arguments
This commit is contained in:
Xing 2014-08-21 16:32:24 +08:00
commit ea92c122a5

View File

@ -76,7 +76,7 @@ func decodeResponse(data []byte) (resp *Response, l int, err error) {
case dtJobCreated: case dtJobCreated:
resp.Handle = string(dt) resp.Handle = string(dt)
case dtStatusRes, dtWorkData, dtWorkWarning, dtWorkStatus, case dtStatusRes, dtWorkData, dtWorkWarning, dtWorkStatus,
dtWorkComplete, dtWorkFail, dtWorkException: dtWorkComplete, dtWorkException:
s := bytes.SplitN(dt, []byte{'\x00'}, 2) s := bytes.SplitN(dt, []byte{'\x00'}, 2)
if len(s) >= 2 { if len(s) >= 2 {
resp.Handle = string(s[0]) resp.Handle = string(s[0])
@ -85,6 +85,14 @@ func decodeResponse(data []byte) (resp *Response, l int, err error) {
err = fmt.Errorf("Invalid data: %v", data) err = fmt.Errorf("Invalid data: %v", data)
return return
} }
case dtWorkFail:
s := bytes.SplitN(dt, []byte{'\x00'}, 2)
if len(s) >= 1 {
resp.Handle = string(s[0])
} else {
err = fmt.Errorf("Invalid data: %v", data)
return
}
case dtEchoRes: case dtEchoRes:
fallthrough fallthrough
default: default: