def recv_by_special_id(self, command_id=None):
if command_id:
expected_id = command_id
else:
expected_id = self._command_id
ws_result = []
ws_instance = self._tab.get("ws_instance")
while True:
try:
result = ws_instance.recv()
except websocket.WebSocketTimeoutException:
return ws_result
if self._debug:
print("[DEBUG] result: {0}".format(result))
if not result:
return ws_result
# ????
ws_result.append(result)
# ?????????
formatted_result = json.loads(result)
event_name = formatted_result.get("method")
params = formatted_result.get("params")
self._call_event_listener(event_name, params)
# ??????
if int(formatted_result.get("id", 0)) == expected_id-1:
break
return ws_result
评论列表
文章目录