Class: ONVIF::EventAction::GetEventProperties

Inherits:
Action
  • Object
show all
Defined in:
lib/ruby_onvif_client/event_handing/get_event_properties.rb

Instance Method Summary collapse

Methods inherited from Action

#attribute, #callback, #create_event_onvif_message, #create_media_onvif_message, #create_ptz_onvif_message, #initialize, #send_message, #value

Constructor Details

This class inherits a constructor from ONVIF::Action

Instance Method Details

#run(cb) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ruby_onvif_client/event_handing/get_event_properties.rb', line 6

def run cb
    message = Message.new namespaces: {:'xmlns:wsdl' => 'http://www.onvif.org/ver10/events/wsdl'}
    message.body =  ->(xml) do
        xml.wsdl(:GetEventProperties)
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            # users = []
            step1 = false
            step2 = false
            step3 = false
            step4 = false
            step5 = false
            xml_doc.xpath('//wsnt:TopicExpressionDialect').each do |node|
                if node.content == 'http://docs.oasis-open.org/wsn/t-1/TopicExpression/Concrete'
                    step1 = true
                elsif node.content == 'http://www.onvif.org/ver10/tev/topicExpression/ConcreteSet'
                    step2 = true
                end    
            end
            step3 = true if xml_doc.xpath('//tev:MessageContentFilterDialect').first.content == 'http://www.onvif.org/ver10/tev/messageContentFilter/ItemFilter'
            topic_namespace = xml_doc.xpath('//tev:TopicNamespaceLocation').first.content
            step4 = true if topic_namespace.include? "http://"
            #puts xml_doc.xpath('//wstop:TopicSet').size
            #step5 = true unless xml_doc.xpath('//wstop:TopicSet').size.empty?
            puts step1, step2, step3, step4, step5
            if step1 and step2 and step3 and step4# and step5
                callback cb, success, result
            else
                callback cb, false, result
            end
        else
            callback cb, success, result
        end
    end
end