gdscript.ProtocolRegistrationTemplate.gd Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protocol Show documentation
Show all versions of protocol Show documentation
zfoo protocol is binary serialization framework for Java/C++/js/ts/C#/Go/Lua/GDScript/Python
The newest version!
class ${protocol_name}Registration:
func write(buffer: ByteBuffer, packet: Object):
if (packet == null):
buffer.writeInt(0)
return
${protocol_write_serialization}
pass
func read(buffer: ByteBuffer):
var length = buffer.readInt()
if (length == 0):
return null
var beforeReadIndex = buffer.getReadOffset()
var packet = buffer.newInstance(${protocol_id})
${protocol_read_deserialization}
if (length > 0):
buffer.setReadOffset(beforeReadIndex + length)
return packet