Class: Pants::Readers::UDPReader
- Inherits:
-
BaseReader
- Object
- BaseReader
- Pants::Readers::UDPReader
- Includes:
- LogSwitch::Mixin
- Defined in:
- lib/pants/readers/udp_reader.rb
Overview
This is the interface for UDPReaderConnections. It controls what happens when the you want to start it up and stop it.
Instance Attribute Summary
Attributes inherited from BaseReader
#core_stopper_callback, #write_to_channel, #writers
Instance Method Summary collapse
-
#initialize(host, port, core_stopper_callback) ⇒ UDPReader
constructor
A new instance of UDPReader.
-
#start ⇒ Object
Starts reading on the UDP IP and port and pushing packets to the channel.
Methods inherited from BaseReader
#add_seam, #add_writer, #read_object, #remove_writer, #running?, #stop!, #write_to
Constructor Details
#initialize(host, port, core_stopper_callback) ⇒ UDPReader
Returns a new instance of UDPReader.
60 61 62 63 64 65 66 |
# File 'lib/pants/readers/udp_reader.rb', line 60 def initialize(host, port, core_stopper_callback) @read_object = "udp://#{host}:#{port}" @host = host @port = port super(core_stopper_callback) end |
Instance Method Details
#start ⇒ Object
Starts reading on the UDP IP and port and pushing packets to the channel.
69 70 71 72 73 74 75 76 77 |
# File 'lib/pants/readers/udp_reader.rb', line 69 def start callback = EM.Callback do log "Adding a #{self.class} at #{@host}:#{@port}..." EM.open_datagram_socket(@host, @port, UDPReaderConnection, @write_to_channel, starter) end super(callback) end |