This commit is contained in:
crusader 2017-11-03 14:55:26 +09:00
parent d168f251ac
commit 3a505e6883
4 changed files with 11 additions and 11 deletions

View File

@ -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.

View File

@ -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

View File

@ -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()
}

View File

@ -77,16 +77,16 @@ func (rr *rpcRegistry) Invoke(codec protocol.RegistryCodec) (result interface{},
// Decode the args.
var in []reflect.Value
paramValues := methodSpec.paramValues
params := methodSpec.getInterfaces()
if nil != paramValues {
params := methodSpec.getInterfaces()
if errRead := codec.ReadParams(params); errRead != nil {
if nil != params && 0 < len(params) {
if errRead := codec.ReadParams(&params); 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)