All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ruby.ProtocolManagerTemplate.rb Maven / Gradle / Ivy

Go to download

zfoo protocol is binary serialization framework for Java/C++/js/ts/C#/Go/Lua/GDScript/Python

The newest version!
${protocol_imports}


class ProtocolManager
  @@protocols = Array.new(32767)
  @@protocolIdMap = Hash.new()

  def self.initProtocol()
  	${protocol_manager_registrations}
  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.read(buffer)
  	protocolId = buffer.readShort()
  	protocol = @@protocols[protocolId]
  	packet = protocol.read(buffer)
  	return packet
  end
end




© 2015 - 2024 Weber Informatics LLC | Privacy Policy