mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-05-21 10:26:32 +00:00
feat[protocol]: 提升协议的兼容性,协议向前兼容
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
-- @author jaysunxiao
|
||||
-- @version 1.0
|
||||
-- @since 2021-03-27 15:18
|
||||
-- @version 3.0
|
||||
|
||||
local SimpleObject = {}
|
||||
|
||||
@@ -15,27 +14,25 @@ function SimpleObject:new(c, g)
|
||||
end
|
||||
|
||||
function SimpleObject:protocolId()
|
||||
return 1163
|
||||
return 104
|
||||
end
|
||||
|
||||
function SimpleObject:write(byteBuffer, packet)
|
||||
if packet == null then
|
||||
byteBuffer:writeBoolean(false)
|
||||
function SimpleObject:write(buffer, packet)
|
||||
if buffer:writePacketFlag(packet) then
|
||||
return
|
||||
end
|
||||
byteBuffer:writeBoolean(true)
|
||||
byteBuffer:writeInt(packet.c)
|
||||
byteBuffer:writeBoolean(packet.g)
|
||||
buffer:writeInt(packet.c)
|
||||
buffer:writeBoolean(packet.g)
|
||||
end
|
||||
|
||||
function SimpleObject:read(byteBuffer)
|
||||
if not(byteBuffer:readBoolean()) then
|
||||
function SimpleObject:read(buffer)
|
||||
if not(buffer:readBoolean()) then
|
||||
return nil
|
||||
end
|
||||
local packet = SimpleObject:new()
|
||||
local result0 = byteBuffer:readInt()
|
||||
local result0 = buffer:readInt()
|
||||
packet.c = result0
|
||||
local result1 = byteBuffer:readBoolean()
|
||||
local result1 = buffer:readBoolean()
|
||||
packet.g = result1
|
||||
return packet
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user