Class: SNMP4EM::Handler

Inherits:
EventMachine::Connection
  • Object
show all
Defined in:
lib/snmp4em/handler.rb

Instance Method Summary collapse

Instance Method Details

#receive_data(data) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/snmp4em/handler.rb', line 3

def receive_data(data)
  begin
    message = SNMP::Message.decode(data)
  rescue Exception => err
    # the request that this malformed response corresponds to
    # will timeout and retry
    return
  end
  
  response = message.pdu

  #
  # in the event of a timeout retry, the request will have been 
  # pruned from the Manager, so the response is to an expired
  # request, ignore it.
  #

  if request = Manager.pending_requests[response.request_id]
    request.handle_response(response)
  end
end