ing
This commit is contained in:
parent
66c4770b07
commit
cdcfb562d3
@ -267,8 +267,11 @@ func (c *client) rpcWriter(stopChan <-chan struct{}, writerDone chan<- error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var requestID interface{}
|
||||||
err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, cs.ID)
|
if 0 < cs.ID {
|
||||||
|
requestID = cs.ID
|
||||||
|
}
|
||||||
|
err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, requestID)
|
||||||
if !cs.hasResponse {
|
if !cs.hasResponse {
|
||||||
cs.Error = err
|
cs.Error = err
|
||||||
cs.Done()
|
cs.Done()
|
||||||
@ -296,7 +299,8 @@ func (c *client) rpcReader(readerDone chan<- error) {
|
|||||||
crn, err := c.ch.GetCodec().NewResponseOrNotify(c.conn)
|
crn, err := c.ch.GetCodec().NewResponseOrNotify(c.conn)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err)
|
err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err)
|
||||||
return
|
logging.Logger().Error(err.Error())
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if crn.IsResponse() {
|
if crn.IsResponse() {
|
||||||
@ -305,7 +309,8 @@ func (c *client) rpcReader(readerDone chan<- error) {
|
|||||||
err = c.notifyHandle(crn.GetNotify())
|
err = c.notifyHandle(crn.GetNotify())
|
||||||
}
|
}
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
logging.Logger().Error(err.Error())
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ type clientNotify struct {
|
|||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
|
|
||||||
// Object to pass as request parameter to the method.
|
// Object to pass as request parameter to the method.
|
||||||
Params *json.RawMessage `json:"params"`
|
Params *json.RawMessage `json:"params,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -21,7 +21,7 @@ func newClientCodecResponse(raw json.RawMessage) (protocol.ClientCodecResponse,
|
|||||||
releaseClientCodecResponse(ccr)
|
releaseClientCodecResponse(ccr)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if nil == ccr.response.ID {
|
if 0 == ccr.response.ID {
|
||||||
releaseClientCodecResponse(ccr)
|
releaseClientCodecResponse(ccr)
|
||||||
return nil, fmt.Errorf("This is not Response")
|
return nil, fmt.Errorf("This is not Response")
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ func releaseClientCodecResponse(ccr *ClientCodecResponse) {
|
|||||||
ccr.response.Version = ""
|
ccr.response.Version = ""
|
||||||
ccr.response.Result = nil
|
ccr.response.Result = nil
|
||||||
ccr.response.Error = nil
|
ccr.response.Error = nil
|
||||||
ccr.response.ID = nil
|
ccr.response.ID = 0
|
||||||
|
|
||||||
clientCodecResponsePool.Put(ccr)
|
clientCodecResponsePool.Put(ccr)
|
||||||
}
|
}
|
||||||
|
@ -24,12 +24,12 @@ type serverRequest struct {
|
|||||||
Method string `json:"method"`
|
Method string `json:"method"`
|
||||||
|
|
||||||
// A Structured value to pass as arguments to the method.
|
// A Structured value to pass as arguments to the method.
|
||||||
Params *json.RawMessage `json:"params"`
|
Params *json.RawMessage `json:"params,omitempty"`
|
||||||
|
|
||||||
// The request id. MUST be a string, number or null.
|
// The request id. MUST be a string, number or null.
|
||||||
// Our implementation will not do type checking for id.
|
// Our implementation will not do type checking for id.
|
||||||
// It will be copied as it is.
|
// It will be copied as it is.
|
||||||
ID *json.RawMessage `json:"id"`
|
ID *json.RawMessage `json:"id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// serverResponse represents a JSON-RPC response returned by the server.
|
// serverResponse represents a JSON-RPC response returned by the server.
|
||||||
@ -48,7 +48,7 @@ type serverResponse struct {
|
|||||||
Error *Error `json:"error,omitempty"`
|
Error *Error `json:"error,omitempty"`
|
||||||
|
|
||||||
// This must be the same id as the request it is responding to.
|
// This must be the same id as the request it is responding to.
|
||||||
ID *json.RawMessage `json:"id"`
|
ID *json.RawMessage `json:"id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user