| | |
| | | # 心跳信息 |
| | | from huaxin_client import socket_util |
| | | from huaxin_client.client_network import SendResponseSkManager |
| | | from log_module.log import logger_system |
| | | from log_module.log import logger_system, logger_request_api |
| | | from utils import middle_api_protocol, tool |
| | | |
| | | MSG_TYPE_HEART = "heart" |
| | |
| | | API_TYPE_SAVE_RUNNING_DATA = "save_running_data" # 保存运行时数据 |
| | | API_TYPE_GET_CODE_POSITION_INFO = "get_code_position_info" # 获取代码持仓信息 |
| | | API_TYPE_COMMON_REQUEST = "common_request" # 通用请求 |
| | | |
| | | |
| | | |
| | | class ActionCallback(object): |
| | |
| | | try: |
| | | result = socket_util.recv_data(sk)[0] |
| | | if result: |
| | | start_time = time.time() |
| | | try: |
| | | print("接收数据", _type, result) |
| | | result_json = json.loads(result) |
| | |
| | | SendResponseSkManager.send_error_response(_type, request_id, client_id, |
| | | {"code": -1, "msg": "签名错误"}) |
| | | continue |
| | | |
| | | if content_type == API_TYPE_TRADE: |
| | | # 交易 |
| | | cls.action_callback.OnTrade(client_id, request_id, data) |
| | |
| | | cls.action_callback.OnCommonRequest(client_id, request_id, data) |
| | | except Exception as e: |
| | | logging.exception(e) |
| | | pass |
| | | finally: |
| | | use_time = int(time.time() - start_time) |
| | | if use_time > 5: |
| | | result_json = json.loads(result) |
| | | logger_request_api.info(f"超时5s以上:{result_json['data']['type']}") |
| | | # 发送响应 |
| | | sk.send(json.dumps({"type": "cmd_recieve"}).encode('utf-8')) |
| | | else: |