在 Protocol Buffers 中分离消息
Separating messages in Protocol Buffers
我正在使用 Protocol Buffers 构建一个 UDP 消息传递系统。我有几条消息(例如 ChannelUpdate、MessageCreate、ACK)。如果我向远程发送消息,我如何发送我正在发送的消息类型?
最好的办法是始终发送相同的消息类型:具有 其他消息之一的根消息。例如:
message SomeRoot {
oneof content {
ChannelUpdate channelUpdate = 1;
MessageCreate msgCreate = 2;
// etc
}
}
现在您正在使用内置协议功能来执行逻辑。
我正在使用 Protocol Buffers 构建一个 UDP 消息传递系统。我有几条消息(例如 ChannelUpdate、MessageCreate、ACK)。如果我向远程发送消息,我如何发送我正在发送的消息类型?
最好的办法是始终发送相同的消息类型:具有 其他消息之一的根消息。例如:
message SomeRoot {
oneof content {
ChannelUpdate channelUpdate = 1;
MessageCreate msgCreate = 2;
// etc
}
}
现在您正在使用内置协议功能来执行逻辑。