pomelo-rpc icon indicating copy to clipboard operation
pomelo-rpc copied to clipboard

不带回调的RPC会导致RPC服务器得到的参数不正确

Open liuyanghejerry opened this issue 11 years ago • 3 comments

如果一个RPC调用不需要知道它的结果,那么就不应该设置一个回调函数。

但是如果不给RPC调用设置回调函数,则RPC服务器会在接受参数时,将最后一个参数误传为 这里 的函数。

重现案例如下:

self.app.rpc.any.anyRemote.fun(session, somevar, somevar,
                                        {
                                          "somearg": 1
                                        });
// ...
anyRemote.prototype.fun = function(somevar, somevar, lastarg) {
  // 这里会发现lastarg不是代码上面的最后一个对象,而是pomelo-rpc中的一个函数
};
self.app.rpc.any.anyRemote.fun(session, somevar, somevar,
                                        {
                                          "somearg": 1
                                        }, function(){});
// ...
anyRemote.prototype.fun = function(somevar, somevar, lastarg) {
  // 这样才可以拿到正确的lastarg
};

这是一个设计,还是一个实现缺陷?

liuyanghejerry avatar May 09 '14 03:05 liuyanghejerry

这个是之前的设计问题,rpc必须有回调函数

py8765 avatar May 09 '14 06:05 py8765

那这个设计会改变吗?如果不会的话,就关了这个issue吧

liuyanghejerry avatar May 09 '14 06:05 liuyanghejerry

可以不带回调函数的pr 已经提交.

whtiehack avatar May 05 '16 15:05 whtiehack