LuaDistributesValhallaInstance = {} LuaDistributesValhallaInstance.sysID = 0 LuaDistributesValhallaInstance.cmdID = 0 function LuaDistributesValhallaInstance.ExtraPacket(memStream) -- print('ExtraPacket:'..memStream.Length) local binaryReader = CS.BinaryMessageHandle.GetLuaPacketReader(memStream) local sysID = binaryReader:ReadByte() local cmdID = binaryReader:ReadByte() packet = LuaDistributesValhallaInstance.ReadPacket(binaryReader) return packet end function LuaDistributesValhallaInstance.SendPacket(packet) local message = CS.BinaryMessageHandle.CreateMessage(LuaDistributesValhallaInstance.sysID, LuaDistributesValhallaInstance.cmdID) if(packet['id'] == nil) then packet['id'] = 0 end message:WriteInt(packet['id']) if(states == nil) then states = {} end message:WriteInt(#packet['states']) for k,v in ipairs(packet['states']) do if(v == nil) then v = 0 end message:WriteByte(v) end message:Send() end function LuaDistributesValhallaInstance.ReadPacket(binaryReader) local packet = {} packet['id'] = binaryReader:ReadInt32() packet['states'] = {} local statesCnt = binaryReader:ReadInt32() for i=1,statesCnt,1 do packet['states'][i] = binaryReader:ReadByte() end return packet end