Class: EventMachine::DatagramObject

Inherits:
Selectable show all
Defined in:
lib/pr_eventmachine.rb

Direct Known Subclasses

EvmaUDPSocket

Instance Attribute Summary

Attributes inherited from Selectable

#io, #uuid

Instance Method Summary collapse

Methods inherited from Selectable

#close_scheduled?, #get_peername

Constructor Details

#initialize(io) ⇒ DatagramObject

Returns a new instance of DatagramObject.



596
597
598
599
# File 'lib/pr_eventmachine.rb', line 596

def initialize io
  super io
  @outbound_q = []
end

Instance Method Details

#select_for_reading?Boolean

#select_for_reading?

Returns:

  • (Boolean)


622
623
624
# File 'lib/pr_eventmachine.rb', line 622

def select_for_reading?
  true
end

#select_for_writing?Boolean

#select_for_writing?

Returns:

  • (Boolean)


610
611
612
613
614
615
616
617
618
619
# File 'lib/pr_eventmachine.rb', line 610

def select_for_writing?
  unless @close_scheduled
    if @outbound_q.empty?
      @close_scheduled = true if @close_requested
      false
    else
      true
    end
  end
end

#send_datagram(data, target) ⇒ Object

#send_datagram



602
603
604
605
606
607
# File 'lib/pr_eventmachine.rb', line 602

def send_datagram data, target
  # TODO, coalesce here perhaps by being smarter about appending to @outbound_q.last?
  unless @close_scheduled or @close_requested
    @outbound_q << [data.to_s, target]
  end
end