详细了解列表相关的编解码规则
diff --git a/README.md b/README.md
index d71578b..61f54e7 100644
--- a/README.md
+++ b/README.md
@@ -76,4 +76,4 @@
* 部分实现参考了dubbo的Java源码中的实现
* 对于所有的字符串,在网络传输前进行编码,编码一律使用unicode来完成,如果一个字符串是str则先将其decode为unicode之后再进行操作;
* 对于所有的字符串,在网络上获取到的数据之后进行解码,解码得到的字符串是unicode,之后将其encode为str再交给客户程序;
-* 支持传输utf-8编码和Emoji🧐
\ No newline at end of file
+* 支持传输utf-8编码和Emoji😋
\ No newline at end of file
diff --git a/dubbo/client.py b/dubbo/client.py
index c6f76c1..6c149f4 100644
--- a/dubbo/client.py
+++ b/dubbo/client.py
@@ -28,6 +28,9 @@
:param zk_register: zookeeper注册中心管理端,参见类:ZkRegister
:param host: 远程主机地址,用于绕过zookeeper进行直连,例如:172.21.4.98:20882
"""
+ if not zk_register and not host:
+ raise RegisterException('zk_register和host至少需要填入一个')
+
self.__interface = interface
self.__version = version
self.__dubbo_version = dubbo_version
diff --git a/dubbo/codec/decoder.py b/dubbo/codec/decoder.py
index 8706d12..0e133dc 100644
--- a/dubbo/codec/decoder.py
+++ b/dubbo/codec/decoder.py
@@ -260,30 +260,34 @@
result = []
self.objects.append(result)
value = self.read_byte()
+ # 固定长度的有类型短小列表
if 0x70 <= value <= 0x77:
_type = self.read_type() # type对于Python来说没有用处
length = value - 0x70
for i in range(length):
result.append(self.read_next())
+ # 固定长度的无类型短小列表
elif 0x78 <= value <= 0x7f:
length = value - 0x78
for i in range(length):
result.append(self.read_next())
- elif value == 0x55:
- _type = self.read_type()
- # 数组的内容为空
+ # 固定长度的有类型列表
elif value == 0x56:
_type = self.read_type()
length = self.read_int()
for i in range(length):
result.append(self.read_next())
- elif value == 0x57:
- pass
- # 数组的内容为空
+ # 固定长度的无类型列表
elif value == 0x58:
length = self.read_int()
for i in range(length):
result.append(self.read_next())
+ # 可变长度的有类型列表
+ elif value == 0x55:
+ _type = self.read_type()
+ # 可变长度的无类型列表
+ elif value == 0x57:
+ pass
return result
@ranges((0xd8, 0xff), (0x38, 0x3f), 0x59, ord('L'))
diff --git a/tests/run_test.py b/tests/run_test.py
index 9fa2597..3fa82f4 100644
--- a/tests/run_test.py
+++ b/tests/run_test.py
@@ -16,17 +16,20 @@
# self.dubbo = DubboClient('com.qianmi.pc.item.api.spu', host='172.21.36.82:20880')
def test_run(self):
- channel = Object('com.qianmi.pc.base.api.constants.ChannelEnum')
- channel['name'] = 'D2C'
+ # channel = Object('com.qianmi.pc.base.api.constants.ChannelEnum')
+ # channel['name'] = 'D2C'
+ #
+ # spu_query_request = Object('com.qianmi.pc.item.api.spu.request.SpuQueryRequest')
+ # spu_query_request['chainMasterId'] = 'A000000'
+ # spu_query_request['channel'] = channel
+ # spu_query_request['pageSize'] = 2000
+ #
+ # result = self.spu_query_provider.call('query', spu_query_request)
+ # pretty_print(result)
+ # print len(result['dataList'])
- spu_query_request = Object('com.qianmi.pc.item.api.spu.request.SpuQueryRequest')
- spu_query_request['chainMasterId'] = 'A000000'
- spu_query_request['channel'] = channel
- spu_query_request['pageSize'] = 2000
-
- result = self.spu_query_provider.call('query', spu_query_request)
- pretty_print(result)
- print len(result['dataList'])
+ dubbo_cli = DubboClient('me.hourui.echo.provider.Echo', host='127.0.0.1:20880')
+ dubbo_cli.call('echo11')
def pretty_print(value):