Class: Dnsruby::EventMachineInterface::EmUdpHandler
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- Dnsruby::EventMachineInterface::EmUdpHandler
- Includes:
- EM::Deferrable
- Defined in:
- lib/Dnsruby/event_machine_interface.rb
Overview
:nodoc: all
Direct Known Subclasses
Instance Attribute Summary collapse
-
#closing ⇒ Object
Returns the value of attribute closing.
-
#timeout_time ⇒ Object
Returns the value of attribute timeout_time.
Instance Method Summary collapse
- #post_init ⇒ Object
- #process_incoming_message(data) ⇒ Object
- #receive_data(dgm) ⇒ Object
- #send_timeout ⇒ Object
- #send_to_client(msg, bytes, err) ⇒ Object
- #unbind ⇒ Object
Instance Attribute Details
#closing ⇒ Object
Returns the value of attribute closing.
179 180 181 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 179 def closing @closing end |
#timeout_time ⇒ Object
Returns the value of attribute timeout_time.
179 180 181 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 179 def timeout_time @timeout_time end |
Instance Method Details
#post_init ⇒ Object
180 181 182 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 180 def post_init @closing=false end |
#process_incoming_message(data) ⇒ Object
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 188 def (data) TheLog.debug("Processing incoming message, #{data.length} bytes") ans=nil begin ans = Message.decode(data) rescue Exception => e TheLog.error("Decode error! #{e.class}, #{e}\nfor msg (length=#{data.length}) : #{data}") @closing=true close_connection send_to_client(nil, nil, e) return end TheLog.debug("#{ans}") ans.answerfrom=(@args[:server]) ans.answersize=(data.length) exception = ans.header.get_exception @closing=true close_connection send_to_client(ans, data, exception) end |
#receive_data(dgm) ⇒ Object
183 184 185 186 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 183 def receive_data(dgm) TheLog.debug("UDP receive_data called") (dgm) end |
#send_timeout ⇒ Object
224 225 226 227 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 224 def send_timeout TheLog.debug("Sending timeout to client") send_to_client(nil, nil, ResolvTimeout.new("Query timed out")) end |
#send_to_client(msg, bytes, err) ⇒ Object
228 229 230 231 232 233 234 235 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 228 def send_to_client(msg, bytes, err) # We call set_defered_status when done if (err != nil) set_deferred_status :failed, msg, err else set_deferred_status :succeeded, msg, bytes end end |
#unbind ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/Dnsruby/event_machine_interface.rb', line 209 def unbind TheLog.debug("Unbind called") if (!@closing) if (@timeout_time <= Time.now + 1) send_timeout else #@TODO@ RAISE OTHER NETWORK ERROR! TheLog.debug("Sending IOError to client") send_to_client(nil, nil, IOError.new("Network error")) end end @closing=false # Take the last send off the list of outstanding sends EventMachineInterface.remove_from_outstanding(self) end |