This commit is contained in:
crusader 2017-09-28 15:31:58 +09:00
parent 0c819ad340
commit b1eb6aa5f6

View File

@ -209,25 +209,36 @@ func (c *client) input() {
var buff []byte var buff []byte
for err == nil { for err == nil {
res = protocol.Response{}
if messageType, buff, err = c.conn.ReadMessage(); nil != err { if messageType, buff, err = c.conn.ReadMessage(); nil != err {
logging.Logger.Error(fmt.Sprintf("Client: Reader error[%v]", err)) logging.Logger.Error(fmt.Sprintf("Client: Reader error[%v]", err))
continue continue
} }
logging.Logger.Debug(fmt.Sprintf("Client: messageType:%d", messageType)) logging.Logger.Debug(fmt.Sprintf("Client: messageType:%d", messageType))
if err = json.Unmarshal(buff, &res); nil != err { if err = json.Unmarshal(buff, &noti); nil != err {
noti = protocol.Notification{} if err = json.Unmarshal(buff, &res); nil != err {
if err = json.Unmarshal(buff, &noti); nil != err {
logging.Logger.Error(fmt.Sprintf("Client: Decode error[%v]", err)) logging.Logger.Error(fmt.Sprintf("Client: Decode error[%v]", err))
continue continue
} else { } else {
c.onNotification(noti) if err = c.onResponse(res); nil != err {
logging.Logger.Error(fmt.Sprintf("Client: Response error[%v]", err))
continue
}
} }
} else { } else {
err = c.onResponse(res) c.onNotification(noti)
} }
// if err = json.Unmarshal(buff, &res); nil != err {
// if err = json.Unmarshal(buff, &noti); nil != err {
// logging.Logger.Error(fmt.Sprintf("Client: Decode error[%v]", err))
// continue
// } else {
// c.onNotification(noti)
// }
// } else {
// err = c.onResponse(res)
// }
} }
// Terminate pending calls. // Terminate pending calls.
c.sendMutex.Lock() c.sendMutex.Lock()