Module: SteamPacketFactory
- Defined in:
- lib/steam/packets/steam_packet_factory.rb
Overview
This module provides functionality to handle raw packet data, including data split into several UDP / TCP packets and BZIP2 compressed data. It’s the main utility to transform data bytes into packet objects.
Class Method Summary collapse
-
.packet_from_data(raw_data) ⇒ SteamPacket
Creates a new packet object based on the header byte of the given raw data.
-
.reassemble_packet(split_packets, is_compressed = false, packet_checksum = 0) ⇒ SteamPacket
Reassembles the data of a split and/or compressed packet into a single packet object.
Class Method Details
.packet_from_data(raw_data) ⇒ SteamPacket
Creates a new packet object based on the header byte of the given raw data
.reassemble_packet(split_packets, is_compressed = false, packet_checksum = 0) ⇒ SteamPacket
Reassembles the data of a split and/or compressed packet into a single packet object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/steam/packets/steam_packet_factory.rb', line 93 def self.reassemble_packet(split_packets, is_compressed = false, packet_checksum = 0) packet_data = split_packets.join '' if is_compressed begin require 'bzip2-ruby' rescue LoadError raise SteamCondenserError, 'The "bzip2-ruby" gem is not installed. Please install it, if you want to query Source servers sending compressed packets.' end packet_data = Bzip2.decompress packet_data unless Zlib.crc32(packet_data) == packet_checksum raise PacketFormatError, 'CRC32 checksum mismatch of uncompressed packet data.' end end packet_from_data packet_data[4..-1] end |