Class: Steam::Networking::PacketList

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/networking/packet_list.rb

Overview

Holds a list of Packet objects in a non-blocking thread safe queue

Instance Method Summary collapse

Constructor Details

#initializePacketList

Returns a new instance of PacketList.



6
7
8
# File 'lib/steam/networking/packet_list.rb', line 6

def initialize
  @packets = Thread::Queue.new
end

Instance Method Details

#add(packet) ⇒ Object

Adds a Packet to the internal queue

Parameters:

  • packet (Packet)

    the Packet to add



13
14
15
# File 'lib/steam/networking/packet_list.rb', line 13

def add(packet)
  @packets.push(packet)
end

#popPacket

Removes the next message

Returns:

  • (Packet)

    The Packet object



20
21
22
23
24
# File 'lib/steam/networking/packet_list.rb', line 20

def pop
  @packets.pop(true)
rescue ThreadError
  nil
end