Method: Frisky::SSDP::Listener#receive_data
- Defined in:
- lib/frisky/ssdp/listener.rb
#receive_data(response) ⇒ Object
This is the callback called by EventMachine when it receives data on the socket that’s been opened for this connection. In this case, the method parses the SSDP notifications into Hashes and adds them to the appropriate EventMachine::Channel (provided as accessor methods). This effectively means that in each Channel, you get a Hash that represents the headers for each notification that comes in on the socket.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/frisky/ssdp/listener.rb', line 23 def receive_data(response) ip, port = peer_info log "Response from #{ip}:#{port}:\n#{response}\n" parsed_response = parse(response) return unless parsed_response.has_key? :nts if parsed_response[:nts] == 'ssdp:alive' @alive_notifications << parsed_response elsif parsed_response[:nts] == 'ssdp:byebye' @byebye_notifications << parsed_response else raise "Unknown NTS value: #{parsed_response[:nts]}" end end |