Administrator
2023-07-21 6e38541651f27ab802895d780e3047b7e124338b
bug修复
1个文件已修改
20 ■■■■■ 已修改文件
trade/huaxin/trade_server.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
trade/huaxin/trade_server.py
@@ -21,6 +21,7 @@
from trade import deal_big_money_manager, current_price_process_manager
from trade.huaxin import huaxin_trade_api as trade_api, trade_api_server, huaxin_trade_api
from utils import socket_util
trade_data_request_queue = queue.Queue()
@@ -98,9 +99,9 @@
                        data_json = json.loads(data_str)
                    except json.decoder.JSONDecodeError as e:
                        # JSON解析失败
                        sk.sendall(json.dumps(
                            {"code": 100, "msg": f"JSON解析失败:字符串内容:{data_str[:30]}......{data_str[-20:]}"}).encode(
                            encoding='utf-8'))
                        sk.sendall(socket_util.load_header( json.dumps(
                            {"code": 100, "msg": f"JSON解析失败"}).encode(
                            encoding='utf-8')))
                        hx_logger_trade_callback.error(
                            f"json解析失败,字符串长度:{len(data_str)},字符串内容:\"{data_str[:30]}......{data_str[-20:]}\"")
                        continue
@@ -110,7 +111,6 @@
                        trade_api.ClientSocketManager.add_client(client_type, rid, sk)
                        sk.sendall(json.dumps({"type": "register"}).encode(encoding='utf-8'))
                        try:
                            # print("客户端", ClientSocketManager.socket_client_dict)
                            while True:
                                result, header = self.getRecvData(sk)
@@ -133,11 +133,13 @@
                    elif data_json["type"] == "response":
                        # 主动触发的响应
                        client_id = data_json["client_id"]
                        hx_logger_trade_callback.info(f"response:request_id-{data_json['request_id']}")
                        # 设置响应内容
                        trade_api.set_response(client_id, data_json["request_id"], data_json['data'])
                        sk.sendall(json.dumps({"code": 0}).encode(encoding='utf-8'))
                        try:
                            client_id = data_json["client_id"]
                            hx_logger_trade_callback.info(f"response:request_id-{data_json['request_id']}")
                            # 设置响应内容
                            trade_api.set_response(client_id, data_json["request_id"], data_json['data'])
                        finally:
                            sk.sendall(socket_util.load_header(json.dumps({"code": 0}).encode(encoding='utf-8')))
                    elif data_json["type"] == "trade_callback":
                        # 交易回调
                        data_json = data_json["data"]