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

返回服务函数(方法)列表的更改 #11

Open
andot opened this issue Jan 7, 2019 · 0 comments
Open

返回服务函数(方法)列表的更改 #11

andot opened this issue Jan 7, 2019 · 0 comments

Comments

@andot
Copy link
Member

andot commented Jan 7, 2019

Hprose 旧版本协议中,当提交的请求中只包含结束符 'z' 时,返回一个以 'F' 开头的方法名列表。

在这种方式下,无法用一个统一的编解码器来处理所有请求和返回结果,这使得让用户自己定制编解码器这个需求变得十分困难,即使强行实现,也会让编解码器在接口方面显得很不优雅。

所以,在 Hprose 3.0 中,决定使用跟远程调用一样的方式来获取方法名列表。

请求:

Cu~z

响应:

Ra4{u~u#u*s5"hello"}z

这里获取服务列表的方法名用一个特殊字符 ~ 表示,这样可以防止跟正常的远程调用方法名冲突。

返回的结果如同正常调用一样返回一个字符串数组的结果。跟原来相比,仅返回的开始标记不一样,后面的内容是一样的。因此不会增加冗余。

上面的返回列表里面我们看到有3个特殊字符串的方法名,它们分别是 ~#*,其中 ~ 就是上面获取服务方法列表的方法名,# 是 hprose 2.0 中添加推送功能时,增加的用来从服务器端返回客户端唯一标识的方法名。* 是从一开始就有的用来表示统一处理缺失方法的方法名。

另外,hprose 3.0 中还会增加一个用特殊字符 ! 表示的反向调用的方法名(#10)。

以后如果需要扩展特殊功能,也会采用这种方式,只要选择的特殊字符避免与上面 4 个冲突就可以了。

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

1 participant