Class: RSwim::Integration::UDP::Sender
- Inherits:
-
Object
- Object
- RSwim::Integration::UDP::Sender
- Defined in:
- lib/rswim/integration/udp/sender.rb
Instance Method Summary collapse
-
#initialize(port, out_q) ⇒ Sender
constructor
A new instance of Sender.
- #run ⇒ Object
Constructor Details
#initialize(port, out_q) ⇒ Sender
Returns a new instance of Sender.
7 8 9 10 11 |
# File 'lib/rswim/integration/udp/sender.rb', line 7 def initialize(port, out_q) @out_q = out_q @port = port @out_s = UDPSocket.new end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rswim/integration/udp/sender.rb', line 13 def run Async do loop do = @out_q.pop .each do |(host, )| logger.debug "about to send message to #{host} on port #{@port}" Fiber.schedule do @out_s.send(, 0, host, @port) rescue StandardError => e logger.debug("Error while sending: #{e}") end end end end end |