Class: Overlook::Csgo::Demo::PacketHandler
- Inherits:
-
Object
- Object
- Overlook::Csgo::Demo::PacketHandler
- Defined in:
- lib/overlook/csgo/demo/packet_handler.rb
Overview
Determines which handler to use to read a packet and yields that handler along with the message to the block
Defined Under Namespace
Modules: MessageTypes
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #handle(packet) ⇒ Object
-
#initialize(_parser, parser_config) ⇒ PacketHandler
constructor
A new instance of PacketHandler.
Constructor Details
#initialize(_parser, parser_config) ⇒ PacketHandler
Returns a new instance of PacketHandler.
16 17 18 19 |
# File 'lib/overlook/csgo/demo/packet_handler.rb', line 16 def initialize(_parser, parser_config) @parser = _parser @parser_config = parser_config end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
14 15 16 |
# File 'lib/overlook/csgo/demo/packet_handler.rb', line 14 def parser @parser end |
Instance Method Details
#handle(packet) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/overlook/csgo/demo/packet_handler.rb', line 21 def handle(packet) reader = BitReader.new(packet.data) loop do = reader.var_int32 = reader.var_int32 handler = handlers[] if handler && handle?(handler) handler.handle(reader.bytes()) else reader.skip() end break if reader.eof? end end |