init
This commit is contained in:
0
app/util/protocbuf/__init__.py
Normal file
0
app/util/protocbuf/__init__.py
Normal file
18
app/util/protocbuf/msg.proto
Normal file
18
app/util/protocbuf/msg.proto
Normal file
@@ -0,0 +1,18 @@
|
||||
syntax = "proto3";
|
||||
package app.protobuf;
|
||||
option go_package=".;proto";
|
||||
|
||||
message SubMessage1 {
|
||||
int32 field1 = 1;
|
||||
int32 field2 = 2;
|
||||
}
|
||||
|
||||
message SubMessage2 {
|
||||
int32 field1 = 1;
|
||||
string field2 = 2;
|
||||
}
|
||||
|
||||
message MessageBytesExtra {
|
||||
SubMessage1 message1 = 1;
|
||||
repeated SubMessage2 message2 = 3;
|
||||
}
|
||||
54
app/util/protocbuf/msg_pb2.py
Normal file
54
app/util/protocbuf/msg_pb2.py
Normal file
@@ -0,0 +1,54 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: msg.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\tmsg.proto\x12\x0c\x61pp.protobuf\"-\n\x0bSubMessage1\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\x05\x12\x0e\n\x06\x66ield2\x18\x02 \x01(\x05\"-\n\x0bSubMessage2\x12\x0e\n\x06\x66ield1\x18\x01 \x01(\x05\x12\x0e\n\x06\x66ield2\x18\x02 \x01(\t\"m\n\x11MessageBytesExtra\x12+\n\x08message1\x18\x01 \x01(\x0b\x32\x19.app.protobuf.SubMessage1\x12+\n\x08message2\x18\x03 \x03(\x0b\x32\x19.app.protobuf.SubMessage2b\x06proto3')
|
||||
|
||||
|
||||
|
||||
_SUBMESSAGE1 = DESCRIPTOR.message_types_by_name['SubMessage1']
|
||||
_SUBMESSAGE2 = DESCRIPTOR.message_types_by_name['SubMessage2']
|
||||
_MESSAGEBYTESEXTRA = DESCRIPTOR.message_types_by_name['MessageBytesExtra']
|
||||
SubMessage1 = _reflection.GeneratedProtocolMessageType('SubMessage1', (_message.Message,), {
|
||||
'DESCRIPTOR' : _SUBMESSAGE1,
|
||||
'__module__' : 'msg_pb2'
|
||||
# @@protoc_insertion_point(class_scope:app.protobuf.SubMessage1)
|
||||
})
|
||||
_sym_db.RegisterMessage(SubMessage1)
|
||||
|
||||
SubMessage2 = _reflection.GeneratedProtocolMessageType('SubMessage2', (_message.Message,), {
|
||||
'DESCRIPTOR' : _SUBMESSAGE2,
|
||||
'__module__' : 'msg_pb2'
|
||||
# @@protoc_insertion_point(class_scope:app.protobuf.SubMessage2)
|
||||
})
|
||||
_sym_db.RegisterMessage(SubMessage2)
|
||||
|
||||
MessageBytesExtra = _reflection.GeneratedProtocolMessageType('MessageBytesExtra', (_message.Message,), {
|
||||
'DESCRIPTOR' : _MESSAGEBYTESEXTRA,
|
||||
'__module__' : 'msg_pb2'
|
||||
# @@protoc_insertion_point(class_scope:app.protobuf.MessageBytesExtra)
|
||||
})
|
||||
_sym_db.RegisterMessage(MessageBytesExtra)
|
||||
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_SUBMESSAGE1._serialized_start=27
|
||||
_SUBMESSAGE1._serialized_end=72
|
||||
_SUBMESSAGE2._serialized_start=74
|
||||
_SUBMESSAGE2._serialized_end=119
|
||||
_MESSAGEBYTESEXTRA._serialized_start=121
|
||||
_MESSAGEBYTESEXTRA._serialized_end=230
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
34
app/util/protocbuf/readme.md
Normal file
34
app/util/protocbuf/readme.md
Normal file
@@ -0,0 +1,34 @@
|
||||
# 说明
|
||||
|
||||
## 解析
|
||||
```shell
|
||||
protoc --decode_raw < msg_data.txt
|
||||
```
|
||||
|
||||
## 根据解析结果,设置.proto文件
|
||||
```shell
|
||||
1 {
|
||||
1: 16
|
||||
2: 0
|
||||
}
|
||||
3 {
|
||||
1: 1
|
||||
2: "wxid_4b1t09d63spw22"
|
||||
}
|
||||
3 {
|
||||
1: 7
|
||||
2: "<msgsource>\n\t<alnode>\n\t\t<fr>2</fr>\n\t</alnode>\n\t<sec_msg_node>\n\t\t<uuid>c6680ab2c57499a1a22e44a7eada76e8_</uuid>\n\t</sec_msg_node>\n\t<silence>1</silence>\n\t<membercount>198</membercount>\n\t<signature>v1_Gj7hfmi5</signature>\n\t<tmp_node>\n\t\t<publisher-id></publisher-id>\n\t</tmp_node>\n</msgsource>\n"
|
||||
}
|
||||
3 {
|
||||
1: 2
|
||||
2: "c13acbc95512d1a59bb686d684fd64d8"
|
||||
}
|
||||
3 {
|
||||
1: 4
|
||||
2: "yiluoAK_47\\FileStorage\\Cache\\2023-08\\2286b5852db82f6cbd9c2084ccd52358"
|
||||
}
|
||||
```
|
||||
## 生成python文件
|
||||
```shell
|
||||
protoc --python_out=. msg.proto
|
||||
```
|
||||
19
app/util/protocbuf/roomdata.proto
Normal file
19
app/util/protocbuf/roomdata.proto
Normal file
@@ -0,0 +1,19 @@
|
||||
syntax = "proto3";
|
||||
package app.protobuf;
|
||||
option go_package=".;proto";
|
||||
|
||||
message ChatRoomData {
|
||||
message ChatRoomMember {
|
||||
string wxID = 1;
|
||||
string displayName = 2;
|
||||
int32 state = 3;
|
||||
}
|
||||
repeated ChatRoomMember members = 1;
|
||||
int32 field_2 = 2;
|
||||
int32 field_3 = 3;
|
||||
int32 field_4 = 4;
|
||||
int32 room_capacity = 5;
|
||||
int32 field_6 = 6;
|
||||
int64 field_7 = 7;
|
||||
int64 field_8 = 8;
|
||||
}
|
||||
45
app/util/protocbuf/roomdata_pb2.py
Normal file
45
app/util/protocbuf/roomdata_pb2.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: roomdata.proto
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import message as _message
|
||||
from google.protobuf import reflection as _reflection
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0eroomdata.proto\x12\x0c\x61pp.protobuf\"\x8b\x02\n\x0c\x43hatRoomData\x12:\n\x07members\x18\x01 \x03(\x0b\x32).app.protobuf.ChatRoomData.ChatRoomMember\x12\x0f\n\x07\x66ield_2\x18\x02 \x01(\x05\x12\x0f\n\x07\x66ield_3\x18\x03 \x01(\x05\x12\x0f\n\x07\x66ield_4\x18\x04 \x01(\x05\x12\x15\n\rroom_capacity\x18\x05 \x01(\x05\x12\x0f\n\x07\x66ield_6\x18\x06 \x01(\x05\x12\x0f\n\x07\x66ield_7\x18\x07 \x01(\x03\x12\x0f\n\x07\x66ield_8\x18\x08 \x01(\x03\x1a\x42\n\x0e\x43hatRoomMember\x12\x0c\n\x04wxID\x18\x01 \x01(\t\x12\x13\n\x0b\x64isplayName\x18\x02 \x01(\t\x12\r\n\x05state\x18\x03 \x01(\x05\x62\x06proto3')
|
||||
|
||||
|
||||
|
||||
_CHATROOMDATA = DESCRIPTOR.message_types_by_name['ChatRoomData']
|
||||
_CHATROOMDATA_CHATROOMMEMBER = _CHATROOMDATA.nested_types_by_name['ChatRoomMember']
|
||||
ChatRoomData = _reflection.GeneratedProtocolMessageType('ChatRoomData', (_message.Message,), {
|
||||
|
||||
'ChatRoomMember' : _reflection.GeneratedProtocolMessageType('ChatRoomMember', (_message.Message,), {
|
||||
'DESCRIPTOR' : _CHATROOMDATA_CHATROOMMEMBER,
|
||||
'__module__' : 'roomdata_pb2'
|
||||
# @@protoc_insertion_point(class_scope:app.protobuf.ChatRoomData.ChatRoomMember)
|
||||
})
|
||||
,
|
||||
'DESCRIPTOR' : _CHATROOMDATA,
|
||||
'__module__' : 'roomdata_pb2'
|
||||
# @@protoc_insertion_point(class_scope:app.protobuf.ChatRoomData)
|
||||
})
|
||||
_sym_db.RegisterMessage(ChatRoomData)
|
||||
_sym_db.RegisterMessage(ChatRoomData.ChatRoomMember)
|
||||
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
|
||||
DESCRIPTOR._options = None
|
||||
_CHATROOMDATA._serialized_start=33
|
||||
_CHATROOMDATA._serialized_end=300
|
||||
_CHATROOMDATA_CHATROOMMEMBER._serialized_start=234
|
||||
_CHATROOMDATA_CHATROOMMEMBER._serialized_end=300
|
||||
# @@protoc_insertion_point(module_scope)
|
||||
Reference in New Issue
Block a user