Class: EventMachine::DatagramObject
- Inherits:
-
Selectable
- Object
- Selectable
- EventMachine::DatagramObject
- Defined in:
- lib/pr_eventmachine.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Selectable
Instance Method Summary collapse
-
#get_outbound_data_size ⇒ Object
#get_outbound_data_size.
-
#initialize(io) ⇒ DatagramObject
constructor
A new instance of DatagramObject.
-
#select_for_reading? ⇒ Boolean
#select_for_reading?.
-
#select_for_writing? ⇒ Boolean
#select_for_writing?.
-
#send_datagram(data, target) ⇒ Object
#send_datagram.
Methods inherited from Selectable
#close_scheduled?, #get_peername, #heartbeat, #set_inactivity_timeout
Constructor Details
#initialize(io) ⇒ DatagramObject
Returns a new instance of DatagramObject.
910 911 912 913 |
# File 'lib/pr_eventmachine.rb', line 910 def initialize io super io @outbound_q = [] end |
Instance Method Details
#get_outbound_data_size ⇒ Object
#get_outbound_data_size
941 942 943 |
# File 'lib/pr_eventmachine.rb', line 941 def get_outbound_data_size @outbound_q.inject(0) {|memo,obj| memo += (obj || "").length} end |
#select_for_reading? ⇒ Boolean
#select_for_reading?
936 937 938 |
# File 'lib/pr_eventmachine.rb', line 936 def select_for_reading? true end |
#select_for_writing? ⇒ Boolean
#select_for_writing?
924 925 926 927 928 929 930 931 932 933 |
# File 'lib/pr_eventmachine.rb', line 924 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
916 917 918 919 920 921 |
# File 'lib/pr_eventmachine.rb', line 916 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 |