Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liuyanghejerry opened this issue May 9, 2014 · 3 comments
Open

Comments

@liuyanghejerry
Copy link

如果一个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
};

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

@py8765
Copy link
Collaborator

py8765 commented May 9, 2014

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

@liuyanghejerry
Copy link
Author

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

@whtiehack
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants