ing
This commit is contained in:
parent
d168f251ac
commit
3a505e6883
|
@ -47,7 +47,7 @@ func (ccn *ClientCodecNotify) Method() string {
|
|||
return ccn.notify.Method
|
||||
}
|
||||
|
||||
func (ccn *ClientCodecNotify) ReadParams(args []interface{}) error {
|
||||
func (ccn *ClientCodecNotify) ReadParams(args *[]interface{}) error {
|
||||
if ccn.err == nil && ccn.notify.Params != nil {
|
||||
// Note: if scr.request.Params is nil it's not an error, it's an optional member.
|
||||
// JSON params structured object. Unmarshal to the args object.
|
||||
|
|
|
@ -160,11 +160,11 @@ func (scr *ServerCodecRequest) Method() string {
|
|||
// absence of expected names MAY result in an error being
|
||||
// generated. The names MUST match exactly, including
|
||||
// case, to the method's expected parameters.
|
||||
func (scr *ServerCodecRequest) ReadParams(args []interface{}) error {
|
||||
func (scr *ServerCodecRequest) ReadParams(args *[]interface{}) error {
|
||||
if scr.err == nil && scr.request.Params != nil {
|
||||
// Note: if scr.request.Params is nil it's not an error, it's an optional member.
|
||||
// JSON params structured object. Unmarshal to the args object.
|
||||
if err := json.Unmarshal(*scr.request.Params, &args); err != nil {
|
||||
if err := json.Unmarshal(*scr.request.Params, args); err != nil {
|
||||
// Clearly JSON params is not a structured object,
|
||||
// fallback and attempt an unmarshal with JSON params as
|
||||
// array value and RPC params is struct. Unmarshal into
|
||||
|
|
|
@ -8,6 +8,6 @@ type RegistryCodec interface {
|
|||
// Reads the request and returns the RPC method name.
|
||||
Method() string
|
||||
// Reads the request filling the RPC method args.
|
||||
ReadParams([]interface{}) error
|
||||
ReadParams(args *[]interface{}) error
|
||||
Complete()
|
||||
}
|
||||
|
|
14
registry.go
14
registry.go
|
@ -77,16 +77,16 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec) (result interface{},
|
|||
// Decode the args.
|
||||
|
||||
var in []reflect.Value
|
||||
paramValues := methodSpec.paramValues
|
||||
|
||||
if nil != paramValues {
|
||||
params := methodSpec.getInterfaces()
|
||||
if errRead := codec.ReadParams(params); errRead != nil {
|
||||
|
||||
if nil != params && 0 < len(params) {
|
||||
if errRead := codec.ReadParams(¶ms); errRead != nil {
|
||||
return nil, errRead
|
||||
}
|
||||
in = make([]reflect.Value, len(paramValues)+1)
|
||||
for indexI := 0; indexI < len(paramValues); indexI++ {
|
||||
in[indexI+1] = paramValues[indexI]
|
||||
pCount := len(params)
|
||||
in = make([]reflect.Value, pCount+1)
|
||||
for indexI := 0; indexI < pCount; indexI++ {
|
||||
in[indexI+1] = reflect.ValueOf(params[indexI])
|
||||
}
|
||||
} else {
|
||||
in = make([]reflect.Value, 1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user