Class: ONVIF::EventAction::PullMessages

Inherits:
Action
  • Object
show all
Defined in:
lib/ruby_onvif_client/event_handing/pull_messages.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(options, 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
# File 'lib/ruby_onvif_client/event_handing/pull_messages.rb', line 6

def run options, cb
    message = Message.new namespaces: {:'xmlns:wsdl' => 'http://www.onvif.org/ver10/events/wsdl'}
    message.body =  ->(xml) do
        xml.wsdl(:PullMessages) do
            xml.wsdl :Timeout, options[:time_out]
            xml.wsdl :MessageLimit , options[:message_limit]
        end
    end
    send_message message do |success, result|
        if success
            # xml_doc = Nokogiri::XML(result[:content])
            # addresses = []
            # xml_doc.xpath('//tev:SubscriptionReference').each do |node|
            #     addresses << value(node, 'wsa5:Address')
            # end
            # res = {}
            # puts addresses
            # res[:addresses] = addresses
            # current_time = xml_doc.xpath('//wsnt:CurrentTime').first.content
            # termination_time = xml_doc.xpath('//wsnt:TerminationTime').first.content
            # puts current_time, termination_time
            # res[:current_time] = current_time
            # res[:termination_time] = termination_time
            callback cb, success, result
        else
            callback cb, success, result
        end
    end
end