diff --git a/central/client/client.go b/central/client/client.go index 617cf9a..ed25f67 100644 --- a/central/client/client.go +++ b/central/client/client.go @@ -209,25 +209,36 @@ func (c *client) input() { var buff []byte for err == nil { - res = protocol.Response{} - if messageType, buff, err = c.conn.ReadMessage(); nil != err { logging.Logger.Error(fmt.Sprintf("Client: Reader error[%v]", err)) continue } logging.Logger.Debug(fmt.Sprintf("Client: messageType:%d", messageType)) - if err = json.Unmarshal(buff, &res); nil != err { - noti = protocol.Notification{} - if err = json.Unmarshal(buff, ¬i); nil != err { + if err = json.Unmarshal(buff, ¬i); nil != err { + if err = json.Unmarshal(buff, &res); nil != err { logging.Logger.Error(fmt.Sprintf("Client: Decode error[%v]", err)) continue } else { - c.onNotification(noti) + if err = c.onResponse(res); nil != err { + logging.Logger.Error(fmt.Sprintf("Client: Response error[%v]", err)) + continue + } } } else { - err = c.onResponse(res) + c.onNotification(noti) } + + // if err = json.Unmarshal(buff, &res); nil != err { + // if err = json.Unmarshal(buff, ¬i); 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. c.sendMutex.Lock()