Class: SNMP4EM::NotificationHandler
- Inherits:
-
EventMachine::Connection
- Object
- EventMachine::Connection
- SNMP4EM::NotificationHandler
- Defined in:
- lib/snmp4em/notification_handler.rb
Instance Attribute Summary collapse
-
#callbacks ⇒ Object
Returns the value of attribute callbacks.
Instance Method Summary collapse
Instance Attribute Details
#callbacks ⇒ Object
Returns the value of attribute callbacks.
3 4 5 |
# File 'lib/snmp4em/notification_handler.rb', line 3 def callbacks @callbacks end |
Instance Method Details
#post_init ⇒ Object
5 6 7 |
# File 'lib/snmp4em/notification_handler.rb', line 5 def post_init @callbacks = [] end |
#receive_data(data) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/snmp4em/notification_handler.rb', line 9 def receive_data(data) source_port, source_ip = Socket.unpack_sockaddr_in(get_peername) begin = SNMP::Message.decode(data) rescue Exception => err return end trap = .pdu return unless trap.is_a?(SNMP::SNMPv1_Trap) || trap.is_a?(SNMP::SNMPv2_Trap) trap.source_ip = source_ip @callbacks.each { |callback| callback.yield(.pdu) } end |