mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-08-07 22:22:19 +00:00
test[protocol]: ruby code style
This commit is contained in:
@@ -41,7 +41,6 @@ def byteBufferTest
|
||||
assertEqual(buffer.readDouble(), -99.0)
|
||||
end
|
||||
|
||||
|
||||
ProtocolManager.initProtocol()
|
||||
# data = File.read("D:\\Project\\zfoo\\protocol\\src\\test\\resources\\compatible\\normal-no-compatible.bytes")
|
||||
# data = File.read("D:\\Project\\zfoo\\protocol\\src\\test\\resources\\compatible\\normal-out-compatible.bytes")
|
||||
@@ -60,5 +59,4 @@ newPacket = ProtocolManager.read(newByteBuffer)
|
||||
puts packet.inspect
|
||||
puts newPacket.inspect
|
||||
|
||||
|
||||
byteBufferTest()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -8,41 +8,41 @@ require_relative 'packet/SimpleObject.rb'
|
||||
|
||||
|
||||
class ProtocolManager
|
||||
@@protocols = Array.new(32767)
|
||||
@@protocolIdMap = Hash.new()
|
||||
@@protocols = Array.new(32767)
|
||||
@@protocolIdMap = Hash.new()
|
||||
|
||||
def self.initProtocol()
|
||||
@@protocols[0] = EmptyObjectRegistration.new()
|
||||
@@protocolIdMap[EmptyObject] = 0
|
||||
@@protocols[1] = VeryBigObjectRegistration.new()
|
||||
@@protocolIdMap[VeryBigObject] = 1
|
||||
@@protocols[100] = ComplexObjectRegistration.new()
|
||||
@@protocolIdMap[ComplexObject] = 100
|
||||
@@protocols[101] = NormalObjectRegistration.new()
|
||||
@@protocolIdMap[NormalObject] = 101
|
||||
@@protocols[102] = ObjectARegistration.new()
|
||||
@@protocolIdMap[ObjectA] = 102
|
||||
@@protocols[103] = ObjectBRegistration.new()
|
||||
@@protocolIdMap[ObjectB] = 103
|
||||
@@protocols[104] = SimpleObjectRegistration.new()
|
||||
@@protocolIdMap[SimpleObject] = 104
|
||||
end
|
||||
def self.initProtocol()
|
||||
@@protocols[0] = EmptyObjectRegistration.new()
|
||||
@@protocolIdMap[EmptyObject] = 0
|
||||
@@protocols[1] = VeryBigObjectRegistration.new()
|
||||
@@protocolIdMap[VeryBigObject] = 1
|
||||
@@protocols[100] = ComplexObjectRegistration.new()
|
||||
@@protocolIdMap[ComplexObject] = 100
|
||||
@@protocols[101] = NormalObjectRegistration.new()
|
||||
@@protocolIdMap[NormalObject] = 101
|
||||
@@protocols[102] = ObjectARegistration.new()
|
||||
@@protocolIdMap[ObjectA] = 102
|
||||
@@protocols[103] = ObjectBRegistration.new()
|
||||
@@protocolIdMap[ObjectB] = 103
|
||||
@@protocols[104] = SimpleObjectRegistration.new()
|
||||
@@protocolIdMap[SimpleObject] = 104
|
||||
end
|
||||
|
||||
def self.getProtocol(protocolId)
|
||||
return @@protocols[protocolId]
|
||||
end
|
||||
def self.getProtocol(protocolId)
|
||||
return @@protocols[protocolId]
|
||||
end
|
||||
|
||||
def self.write(buffer, packet)
|
||||
protocolId = @@protocolIdMap[packet.class]
|
||||
buffer.writeShort(protocolId)
|
||||
protocol = @@protocols[protocolId]
|
||||
protocol.write(buffer, packet)
|
||||
end
|
||||
def self.write(buffer, packet)
|
||||
protocolId = @@protocolIdMap[packet.class]
|
||||
buffer.writeShort(protocolId)
|
||||
protocol = @@protocols[protocolId]
|
||||
protocol.write(buffer, packet)
|
||||
end
|
||||
|
||||
def self.read(buffer)
|
||||
protocolId = buffer.readShort()
|
||||
protocol = @@protocols[protocolId]
|
||||
packet = protocol.read(buffer)
|
||||
return packet
|
||||
end
|
||||
def self.read(buffer)
|
||||
protocolId = buffer.readShort()
|
||||
protocol = @@protocols[protocolId]
|
||||
packet = protocol.read(buffer)
|
||||
return packet
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,35 +1,35 @@
|
||||
|
||||
class EmptyObject
|
||||
|
||||
def initialize()
|
||||
|
||||
def initialize()
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class EmptyObjectRegistration
|
||||
def protocolId()
|
||||
return 0
|
||||
end
|
||||
def protocolId()
|
||||
return 0
|
||||
end
|
||||
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
buffer.writeInt(-1)
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
buffer.writeInt(-1)
|
||||
end
|
||||
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = EmptyObject.new()
|
||||
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = EmptyObject.new()
|
||||
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
end
|
||||
end
|
||||
@@ -1,139 +1,139 @@
|
||||
# 常规的对象,取所有语言语法的交集,基本上所有语言都支持下面的语法
|
||||
class NormalObject
|
||||
attr_accessor :a # byte
|
||||
attr_accessor :aaa # byte[]
|
||||
attr_accessor :b # short
|
||||
# 整数类型
|
||||
attr_accessor :c # int
|
||||
attr_accessor :d # long
|
||||
attr_accessor :e # float
|
||||
attr_accessor :f # double
|
||||
attr_accessor :g # bool
|
||||
attr_accessor :jj # string
|
||||
attr_accessor :kk # ObjectA
|
||||
attr_accessor :l # List<int>
|
||||
attr_accessor :ll # List<long>
|
||||
attr_accessor :lll # List<ObjectA>
|
||||
attr_accessor :llll # List<string>
|
||||
attr_accessor :m # Dictionary<int, string>
|
||||
attr_accessor :mm # Dictionary<int, ObjectA>
|
||||
attr_accessor :s # HashSet<int>
|
||||
attr_accessor :ssss # HashSet<string>
|
||||
attr_accessor :outCompatibleValue # int
|
||||
attr_accessor :outCompatibleValue2 # int
|
||||
def initialize()
|
||||
@a = 0
|
||||
@aaa = Array.new()
|
||||
@b = 0
|
||||
@c = 0
|
||||
@d = 0
|
||||
@e = 0.0
|
||||
@f = 0.0
|
||||
@g = false
|
||||
@jj = ""
|
||||
@kk = nil
|
||||
@l = Array.new()
|
||||
@ll = Array.new()
|
||||
@lll = Array.new()
|
||||
@llll = Array.new()
|
||||
@m = Hash.new()
|
||||
@mm = Hash.new()
|
||||
@s = Set.new()
|
||||
@ssss = Set.new()
|
||||
@outCompatibleValue = 0
|
||||
@outCompatibleValue2 = 0
|
||||
end
|
||||
attr_accessor :a # byte
|
||||
attr_accessor :aaa # byte[]
|
||||
attr_accessor :b # short
|
||||
# 整数类型
|
||||
attr_accessor :c # int
|
||||
attr_accessor :d # long
|
||||
attr_accessor :e # float
|
||||
attr_accessor :f # double
|
||||
attr_accessor :g # bool
|
||||
attr_accessor :jj # string
|
||||
attr_accessor :kk # ObjectA
|
||||
attr_accessor :l # List<int>
|
||||
attr_accessor :ll # List<long>
|
||||
attr_accessor :lll # List<ObjectA>
|
||||
attr_accessor :llll # List<string>
|
||||
attr_accessor :m # Dictionary<int, string>
|
||||
attr_accessor :mm # Dictionary<int, ObjectA>
|
||||
attr_accessor :s # HashSet<int>
|
||||
attr_accessor :ssss # HashSet<string>
|
||||
attr_accessor :outCompatibleValue # int
|
||||
attr_accessor :outCompatibleValue2 # int
|
||||
def initialize()
|
||||
@a = 0
|
||||
@aaa = Array.new()
|
||||
@b = 0
|
||||
@c = 0
|
||||
@d = 0
|
||||
@e = 0.0
|
||||
@f = 0.0
|
||||
@g = false
|
||||
@jj = ""
|
||||
@kk = nil
|
||||
@l = Array.new()
|
||||
@ll = Array.new()
|
||||
@lll = Array.new()
|
||||
@llll = Array.new()
|
||||
@m = Hash.new()
|
||||
@mm = Hash.new()
|
||||
@s = Set.new()
|
||||
@ssss = Set.new()
|
||||
@outCompatibleValue = 0
|
||||
@outCompatibleValue2 = 0
|
||||
end
|
||||
end
|
||||
|
||||
class NormalObjectRegistration
|
||||
def protocolId()
|
||||
return 101
|
||||
end
|
||||
def protocolId()
|
||||
return 101
|
||||
end
|
||||
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(857)
|
||||
buffer.writeByte(packet.a)
|
||||
buffer.writeByteArray(packet.aaa)
|
||||
buffer.writeShort(packet.b)
|
||||
buffer.writeInt(packet.c)
|
||||
buffer.writeLong(packet.d)
|
||||
buffer.writeFloat(packet.e)
|
||||
buffer.writeDouble(packet.f)
|
||||
buffer.writeBool(packet.g)
|
||||
buffer.writeString(packet.jj)
|
||||
buffer.writePacket(packet.kk, 102)
|
||||
buffer.writeIntArray(packet.l)
|
||||
buffer.writeLongArray(packet.ll)
|
||||
buffer.writePacketArray(packet.lll, 102)
|
||||
buffer.writeStringArray(packet.llll)
|
||||
buffer.writeIntStringMap(packet.m)
|
||||
buffer.writeIntPacketMap(packet.mm, 102)
|
||||
buffer.writeIntSet(packet.s)
|
||||
buffer.writeStringSet(packet.ssss)
|
||||
buffer.writeInt(packet.outCompatibleValue)
|
||||
buffer.writeInt(packet.outCompatibleValue2)
|
||||
buffer.adjustPadding(857, beforeWriteIndex)
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(857)
|
||||
buffer.writeByte(packet.a)
|
||||
buffer.writeByteArray(packet.aaa)
|
||||
buffer.writeShort(packet.b)
|
||||
buffer.writeInt(packet.c)
|
||||
buffer.writeLong(packet.d)
|
||||
buffer.writeFloat(packet.e)
|
||||
buffer.writeDouble(packet.f)
|
||||
buffer.writeBool(packet.g)
|
||||
buffer.writeString(packet.jj)
|
||||
buffer.writePacket(packet.kk, 102)
|
||||
buffer.writeIntArray(packet.l)
|
||||
buffer.writeLongArray(packet.ll)
|
||||
buffer.writePacketArray(packet.lll, 102)
|
||||
buffer.writeStringArray(packet.llll)
|
||||
buffer.writeIntStringMap(packet.m)
|
||||
buffer.writeIntPacketMap(packet.mm, 102)
|
||||
buffer.writeIntSet(packet.s)
|
||||
buffer.writeStringSet(packet.ssss)
|
||||
buffer.writeInt(packet.outCompatibleValue)
|
||||
buffer.writeInt(packet.outCompatibleValue2)
|
||||
buffer.adjustPadding(857, beforeWriteIndex)
|
||||
end
|
||||
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = NormalObject.new()
|
||||
result0 = buffer.readByte()
|
||||
packet.a = result0
|
||||
array1 = buffer.readByteArray()
|
||||
packet.aaa = array1
|
||||
result2 = buffer.readShort()
|
||||
packet.b = result2
|
||||
result3 = buffer.readInt()
|
||||
packet.c = result3
|
||||
result4 = buffer.readLong()
|
||||
packet.d = result4
|
||||
result5 = buffer.readFloat()
|
||||
packet.e = result5
|
||||
result6 = buffer.readDouble()
|
||||
packet.f = result6
|
||||
result7 = buffer.readBool()
|
||||
packet.g = result7
|
||||
result8 = buffer.readString()
|
||||
packet.jj = result8
|
||||
result9 = buffer.readPacket(102)
|
||||
packet.kk = result9
|
||||
list10 = buffer.readIntArray()
|
||||
packet.l = list10
|
||||
list11 = buffer.readLongArray()
|
||||
packet.ll = list11
|
||||
list12 = buffer.readPacketArray(102)
|
||||
packet.lll = list12
|
||||
list13 = buffer.readStringArray()
|
||||
packet.llll = list13
|
||||
map14 = buffer.readIntStringMap()
|
||||
packet.m = map14
|
||||
map15 = buffer.readIntPacketMap(102)
|
||||
packet.mm = map15
|
||||
set16 = buffer.readIntSet()
|
||||
packet.s = set16
|
||||
set17 = buffer.readStringSet()
|
||||
packet.ssss = set17
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result18 = buffer.readInt()
|
||||
packet.outCompatibleValue = result18
|
||||
end
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result19 = buffer.readInt()
|
||||
packet.outCompatibleValue2 = result19
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = NormalObject.new()
|
||||
result0 = buffer.readByte()
|
||||
packet.a = result0
|
||||
array1 = buffer.readByteArray()
|
||||
packet.aaa = array1
|
||||
result2 = buffer.readShort()
|
||||
packet.b = result2
|
||||
result3 = buffer.readInt()
|
||||
packet.c = result3
|
||||
result4 = buffer.readLong()
|
||||
packet.d = result4
|
||||
result5 = buffer.readFloat()
|
||||
packet.e = result5
|
||||
result6 = buffer.readDouble()
|
||||
packet.f = result6
|
||||
result7 = buffer.readBool()
|
||||
packet.g = result7
|
||||
result8 = buffer.readString()
|
||||
packet.jj = result8
|
||||
result9 = buffer.readPacket(102)
|
||||
packet.kk = result9
|
||||
list10 = buffer.readIntArray()
|
||||
packet.l = list10
|
||||
list11 = buffer.readLongArray()
|
||||
packet.ll = list11
|
||||
list12 = buffer.readPacketArray(102)
|
||||
packet.lll = list12
|
||||
list13 = buffer.readStringArray()
|
||||
packet.llll = list13
|
||||
map14 = buffer.readIntStringMap()
|
||||
packet.m = map14
|
||||
map15 = buffer.readIntPacketMap(102)
|
||||
packet.mm = map15
|
||||
set16 = buffer.readIntSet()
|
||||
packet.s = set16
|
||||
set17 = buffer.readStringSet()
|
||||
packet.ssss = set17
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result18 = buffer.readInt()
|
||||
packet.outCompatibleValue = result18
|
||||
end
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result19 = buffer.readInt()
|
||||
packet.outCompatibleValue2 = result19
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
end
|
||||
end
|
||||
@@ -1,56 +1,56 @@
|
||||
|
||||
class ObjectA
|
||||
attr_accessor :a # int
|
||||
attr_accessor :m # Dictionary<int, string>
|
||||
attr_accessor :objectB # ObjectB
|
||||
attr_accessor :innerCompatibleValue # int
|
||||
def initialize()
|
||||
@a = 0
|
||||
@m = Hash.new()
|
||||
@objectB = nil
|
||||
@innerCompatibleValue = 0
|
||||
end
|
||||
attr_accessor :a # int
|
||||
attr_accessor :m # Dictionary<int, string>
|
||||
attr_accessor :objectB # ObjectB
|
||||
attr_accessor :innerCompatibleValue # int
|
||||
def initialize()
|
||||
@a = 0
|
||||
@m = Hash.new()
|
||||
@objectB = nil
|
||||
@innerCompatibleValue = 0
|
||||
end
|
||||
end
|
||||
|
||||
class ObjectARegistration
|
||||
def protocolId()
|
||||
return 102
|
||||
end
|
||||
def protocolId()
|
||||
return 102
|
||||
end
|
||||
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(201)
|
||||
buffer.writeInt(packet.a)
|
||||
buffer.writeIntStringMap(packet.m)
|
||||
buffer.writePacket(packet.objectB, 103)
|
||||
buffer.writeInt(packet.innerCompatibleValue)
|
||||
buffer.adjustPadding(201, beforeWriteIndex)
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(201)
|
||||
buffer.writeInt(packet.a)
|
||||
buffer.writeIntStringMap(packet.m)
|
||||
buffer.writePacket(packet.objectB, 103)
|
||||
buffer.writeInt(packet.innerCompatibleValue)
|
||||
buffer.adjustPadding(201, beforeWriteIndex)
|
||||
end
|
||||
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = ObjectA.new()
|
||||
result0 = buffer.readInt()
|
||||
packet.a = result0
|
||||
map1 = buffer.readIntStringMap()
|
||||
packet.m = map1
|
||||
result2 = buffer.readPacket(103)
|
||||
packet.objectB = result2
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result3 = buffer.readInt()
|
||||
packet.innerCompatibleValue = result3
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = ObjectA.new()
|
||||
result0 = buffer.readInt()
|
||||
packet.a = result0
|
||||
map1 = buffer.readIntStringMap()
|
||||
packet.m = map1
|
||||
result2 = buffer.readPacket(103)
|
||||
packet.objectB = result2
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result3 = buffer.readInt()
|
||||
packet.innerCompatibleValue = result3
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
end
|
||||
end
|
||||
@@ -1,46 +1,46 @@
|
||||
|
||||
class ObjectB
|
||||
attr_accessor :flag # bool
|
||||
attr_accessor :innerCompatibleValue # int
|
||||
def initialize()
|
||||
@flag = false
|
||||
@innerCompatibleValue = 0
|
||||
end
|
||||
attr_accessor :flag # bool
|
||||
attr_accessor :innerCompatibleValue # int
|
||||
def initialize()
|
||||
@flag = false
|
||||
@innerCompatibleValue = 0
|
||||
end
|
||||
end
|
||||
|
||||
class ObjectBRegistration
|
||||
def protocolId()
|
||||
return 103
|
||||
end
|
||||
def protocolId()
|
||||
return 103
|
||||
end
|
||||
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(4)
|
||||
buffer.writeBool(packet.flag)
|
||||
buffer.writeInt(packet.innerCompatibleValue)
|
||||
buffer.adjustPadding(4, beforeWriteIndex)
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
beforeWriteIndex = buffer.getWriteOffset()
|
||||
buffer.writeInt(4)
|
||||
buffer.writeBool(packet.flag)
|
||||
buffer.writeInt(packet.innerCompatibleValue)
|
||||
buffer.adjustPadding(4, beforeWriteIndex)
|
||||
end
|
||||
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = ObjectB.new()
|
||||
result0 = buffer.readBool()
|
||||
packet.flag = result0
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result1 = buffer.readInt()
|
||||
packet.innerCompatibleValue = result1
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = ObjectB.new()
|
||||
result0 = buffer.readBool()
|
||||
packet.flag = result0
|
||||
if buffer.compatibleRead(beforeReadIndex, length)
|
||||
result1 = buffer.readInt()
|
||||
packet.innerCompatibleValue = result1
|
||||
end
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
end
|
||||
end
|
||||
@@ -1,42 +1,42 @@
|
||||
|
||||
class SimpleObject
|
||||
attr_accessor :c # int
|
||||
attr_accessor :g # bool
|
||||
def initialize()
|
||||
@c = 0
|
||||
@g = false
|
||||
end
|
||||
attr_accessor :c # int
|
||||
attr_accessor :g # bool
|
||||
def initialize()
|
||||
@c = 0
|
||||
@g = false
|
||||
end
|
||||
end
|
||||
|
||||
class SimpleObjectRegistration
|
||||
def protocolId()
|
||||
return 104
|
||||
end
|
||||
def protocolId()
|
||||
return 104
|
||||
end
|
||||
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
buffer.writeInt(-1)
|
||||
buffer.writeInt(packet.c)
|
||||
buffer.writeBool(packet.g)
|
||||
def write(buffer, packet)
|
||||
if packet.nil?
|
||||
buffer.writeInt(0)
|
||||
return
|
||||
end
|
||||
buffer.writeInt(-1)
|
||||
buffer.writeInt(packet.c)
|
||||
buffer.writeBool(packet.g)
|
||||
end
|
||||
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = SimpleObject.new()
|
||||
result0 = buffer.readInt()
|
||||
packet.c = result0
|
||||
result1 = buffer.readBool()
|
||||
packet.g = result1
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
def read(buffer)
|
||||
length = buffer.readInt()
|
||||
if length == 0
|
||||
return nil
|
||||
end
|
||||
beforeReadIndex = buffer.getReadOffset()
|
||||
packet = SimpleObject.new()
|
||||
result0 = buffer.readInt()
|
||||
packet.c = result0
|
||||
result1 = buffer.readBool()
|
||||
packet.g = result1
|
||||
if length > 0
|
||||
buffer.setReadOffset(beforeReadIndex + length)
|
||||
end
|
||||
return packet
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user