Class: ONVIF::DeviceManagementAction::GetNetworkProtocols

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

def run cb
    message = Message.new
    message.body =  ->(xml) do
        xml.wsdl(:GetNetworkProtocols)
    end
    send_message message do |success, result|
        if success
            xml_doc = Nokogiri::XML(result[:content])
            network = []
            xml_doc.xpath('//tds:NetworkProtocols').each do |node|
                network << {
                    name: value(node, 'tt:Name'),
                    enabled: value(node, 'tt:Enabled'),
                    port: value(node, 'tt:Port'),
                    extension: value(node, 'tt:Extension')
                }
            end

            callback cb, success, network
        else
            callback cb, success, result
        end
    end
end