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
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/steam/packets/steam_packet_factory.rb', line 91 def self.reassemble_packet(split_packets, is_compressed = false, packet_checksum = 0) packet_data = split_packets.join '' if is_compressed require 'zlib' begin require 'bz2' packet_data = BZ2.uncompress(packet_data) rescue LoadError raise SteamCondenserException.new('You need to install the libbzip2 interface for Ruby.') end unless Zlib.crc32(packet_data) == packet_checksum raise PacketFormatException.new('CRC32 checksum mismatch of uncompressed packet data.') end end packet_from_data packet_data[4..-1] end |