diff --git a/client/client.go b/client/client.go index fae49d3..aade5e8 100644 --- a/client/client.go +++ b/client/client.go @@ -279,7 +279,8 @@ LOOP: logging.Logger().Debug(err) continue LOOP } - if nil == resCodec.ID() { + + if resCodec.IsNotification() { // notification notiCodec, err := resCodec.Notification() if nil != err { diff --git a/protocol/client_codec.go b/protocol/client_codec.go index 92d9fd1..bb417cc 100644 --- a/protocol/client_codec.go +++ b/protocol/client_codec.go @@ -7,6 +7,7 @@ type ClientCodec interface { } type ClientResponseCodec interface { + IsNotification() bool Notification() (ClientNotificationCodec, error) Result(result interface{}) error Error() *Error diff --git a/protocol/json/client_response.go b/protocol/json/client_response.go index 611c917..3feb036 100644 --- a/protocol/json/client_response.go +++ b/protocol/json/client_response.go @@ -42,6 +42,13 @@ func (crc *ClientResponseCodec) Error() *protocol.Error { return crc.res.Error } +func (crc *ClientResponseCodec) IsNotification() bool { + if nil == crc.res.ID && nil != crc.res.Result { + return true + } + return false +} + func (crc *ClientResponseCodec) Notification() (protocol.ClientNotificationCodec, error) { if nil != crc.res.ID || nil == crc.res.Result { return nil, fmt.Errorf("This is not notification")