Administrator
2025-06-12 4e5eed2226fae6a057c454155565211dbc9349e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""
与中间服务器的通信协议
"""
import json
 
from utils import socket_util
 
SERVER_HOST = '43.138.167.68'
SERVER_PORT = 12880
 
 
def request(data_json):
    if type(data_json) == set:
        data_json = list(data_json)
    data_bytes = socket_util.load_header(json.dumps(data_json).encode('utf-8'))
    sk = socket_util.create_socket(SERVER_HOST, SERVER_PORT)
    try:
        sk.sendall(data_bytes)
        result_str, header_str = socket_util.recv_data(sk)
        result_json = json.loads(result_str)
        if result_json["code"] != 0:
            raise Exception(result_json["msg"])
        return result_json.get("data")
    finally:
        sk.close()
 
 
# ------------------------------Redis协议----------------------------------
def load_redis_cmd(data):
    fdata = {"type": "redis", "data": {"ctype": "cmd", "data": data}}
    return fdata
 
 
def load_redis_cmds(datas):
    fdata = {"type": "redis", "data": {"ctype": "cmds", "data": datas}}
    return fdata
 
 
# ------------------------------Mysql协议----------------------------------
def load_mysql_cmd(data):
    fdata = {"type": "mysql", "data": {"ctype": "cmd", "data": data}}
    return fdata
 
 
# -------------------------------掘金--------------------------------------
 
def load_juejin(path_, data_json):
    fdata = {"type": "juejin", "data": {"ctype": "juejin", "data": {"path": path_, "params": data_json}}}
    return fdata
 
 
# ------------------------------开盘啦-------------------------------------
def load_kpl(url, data, timeout):
    fdata = {"type": "kpl", "data": {"ctype": "kpl", "data": {"url": url, "data": data, "timeout": timeout}}}
    return fdata
 
 
# ------------------------------看盘消息------------------------------------
def load_kp_msg(msg):
    fdata = {"type": "kp_msg", "data": {"ctype": "kp_msg", "data": {"msg": msg}}}
    return fdata
 
 
# ------------------------------L2订阅列表------------------------------------
def load_l2_position_subscript_codes(datas):
    fdata = {"type": "l2_position_subscript_codes", "data": {"ctype": "l2_position_subscript_codes", "data": datas}}
    return fdata
 
 
# ------------------------------消息推送------------------------------------
def load_push_msg(data):
    fdata = {"type": "push_msg", "data": {"ctype": "push_msg", "data": data}}
    return fdata