Module: RCONPacketFactory

Includes:
SteamPacketFactory
Defined in:
lib/steam/packets/rcon/rcon_packet_factory.rb

Class Method Summary collapse

Methods included from SteamPacketFactory

reassemble_packet

Class Method Details

.packet_from_data(raw_data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/steam/packets/rcon/rcon_packet_factory.rb', line 16

def self.packet_from_data(raw_data)
  byte_buffer = StringIO.new raw_data

  byte_buffer.long
  request_id = byte_buffer.long
  header = byte_buffer.long
  data = byte_buffer.cstring

  case header
    when RCONPacket::SERVERDATA_AUTH_RESPONSE then
      return RCONAuthResponse.new(request_id)
    when RCONPacket::SERVERDATA_RESPONSE_VALUE then
      return RCONExecResponse.new(request_id, data)
    else
      raise PacketFormatException.new("Unknown packet with header #{header.to_s(16)} received.")
  end
end