feat[cpp]: compatible field of inside protocol class

This commit is contained in:
godotg
2023-10-15 17:35:25 +08:00
parent 1c87c12035
commit 98504cb124
2 changed files with 11 additions and 5 deletions
@@ -46,10 +46,15 @@ namespace zfoo {
IProtocol *read(ByteBuffer &buffer) override {
auto *packet = new {}();
if (!buffer.readBool()) {
auto length = buffer.readInt();
if (length == 0) {
return packet;
}
auto beforeReadIndex = buffer.readerIndex();
{}
if (length > 0) {
buffer.readerIndex(beforeReadIndex + length);
}
return packet;
}
};