Class: Druzy::Upnp::Event::UpnpServlet

Inherits:
WEBrick::HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/druzy/upnp/event/upnp_event_server.rb

Instance Method Summary collapse

Instance Method Details

#do_NOTIFY(request, response) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/druzy/upnp/event/upnp_event_server.rb', line 44

def do_NOTIFY(request, response)
  @options=@options[0]
  xml = Nokogiri::XML(request.body)
  xml.remove_namespaces!
  #puts xml.to_s
  xml.xpath('propertyset/property').each do |el|
    el.children.each do |child|
      if child.name.to_s == "LastChange"
        child.xpath('Event/InstanceID').each do |el2|
          el2.children.each do |child2|
            @options[:event_server].get_listeners(request['SID']).each do |listener|
              listener.property_change(Druzy::MVC::PropertyChangeEvent.new(request.remote_ip,child2.name.to_s,nil,child2.attribute("val")))
            end
          end
        end
      else
        @options[:event_server].get_listeners(request['SID']).each do |listener|
          listener.property_change(Druzy::MVC::PropertyChangeEvent.new(request.remote_ip,child.name.to_s,nil,child.text))
        end
      end      
    end
  end
  
  response.status = 200
end