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 | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, cs.ID) | ||||
| 		var requestID interface{} | ||||
| 		if 0 < cs.ID { | ||||
| 			requestID = cs.ID | ||||
| 		} | ||||
| 		err = c.ch.GetCodec().Write(c.conn, cs.Method, cs.Args, requestID) | ||||
| 		if !cs.hasResponse { | ||||
| 			cs.Error = err | ||||
| 			cs.Done() | ||||
| @ -296,7 +299,8 @@ func (c *client) rpcReader(readerDone chan<- error) { | ||||
| 		crn, err := c.ch.GetCodec().NewResponseOrNotify(c.conn) | ||||
| 		if nil != err { | ||||
| 			err = fmt.Errorf("Client: Cannot decode response or notify: [%s]", err) | ||||
| 			return | ||||
| 			logging.Logger().Error(err.Error()) | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		if crn.IsResponse() { | ||||
| @ -305,7 +309,8 @@ func (c *client) rpcReader(readerDone chan<- error) { | ||||
| 			err = c.notifyHandle(crn.GetNotify()) | ||||
| 		} | ||||
| 		if nil != err { | ||||
| 			return | ||||
| 			logging.Logger().Error(err.Error()) | ||||
| 			continue | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -47,7 +47,7 @@ type clientNotify struct { | ||||
| 	Method string `json:"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) | ||||
| 		return nil, err | ||||
| 	} | ||||
| 	if nil == ccr.response.ID { | ||||
| 	if 0 == ccr.response.ID { | ||||
| 		releaseClientCodecResponse(ccr) | ||||
| 		return nil, fmt.Errorf("This is not Response") | ||||
| 	} | ||||
| @ -81,7 +81,7 @@ func releaseClientCodecResponse(ccr *ClientCodecResponse) { | ||||
| 	ccr.response.Version = "" | ||||
| 	ccr.response.Result = nil | ||||
| 	ccr.response.Error = nil | ||||
| 	ccr.response.ID = nil | ||||
| 	ccr.response.ID = 0 | ||||
| 
 | ||||
| 	clientCodecResponsePool.Put(ccr) | ||||
| } | ||||
|  | ||||
| @ -24,12 +24,12 @@ type serverRequest struct { | ||||
| 	Method string `json:"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. | ||||
| 	// Our implementation will not do type checking for id. | ||||
| 	// 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. | ||||
| @ -48,7 +48,7 @@ type serverResponse struct { | ||||
| 	Error *Error `json:"error,omitempty"` | ||||
| 
 | ||||
| 	// 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