feat: TCP协议支持protobuf序列化,保留JSON兼容
- 新增 tcp_messages_pb2.py protobuf Python绑定 - msg_handler.cpp: 新增 make_packet_pb/raw bytes打包, parse_packet_raw/raw解析 - archery_netcore.cpp: 注册 make_packet_pb/parse_packet_raw - network.py: 新增 _use_proto 标志,_make_send_packet/_parse_recv 自动选择proto/JSON - 登录version加+proto后缀标识proto模式 - protobuf序列化/反序列化失败时自动回退JSON
This commit is contained in:
@@ -56,10 +56,17 @@ PYBIND11_MODULE(archery_netcore, m) {
|
||||
m.def("make_packet", &netcore::make_packet,
|
||||
"Pack TCP packet: header (len+type+checksum) + JSON body",
|
||||
py::arg("msg_type"), py::arg("body_dict"));
|
||||
|
||||
|
||||
m.def("make_packet_pb", &netcore::make_packet_pb,
|
||||
"Pack TCP packet: header (len+type+checksum) + raw bytes body (for protobuf)",
|
||||
py::arg("msg_type"), py::arg("body_bytes"));
|
||||
|
||||
m.def("parse_packet", &netcore::parse_packet,
|
||||
"Parse TCP packet, return (msg_type, body_dict)");
|
||||
|
||||
m.def("parse_packet_raw", &netcore::parse_packet_raw,
|
||||
"Parse TCP packet, return (msg_type, body_bytes) without JSON parsing");
|
||||
|
||||
m.def("get_config", &get_config, "Get system configuration");
|
||||
|
||||
m.def(
|
||||
|
||||
Reference in New Issue
Block a user