Class: EasyUpnp::ClientWrapper
- Inherits:
-
Object
- Object
- EasyUpnp::ClientWrapper
- Defined in:
- lib/easy_upnp/control_point/client_wrapper.rb
Instance Method Summary collapse
- #call(action_name, args) ⇒ Object
-
#initialize(endpoint, urn, call_options, advanced_typecasting, log_enabled, log_level, cookies) ⇒ ClientWrapper
constructor
A new instance of ClientWrapper.
Constructor Details
#initialize(endpoint, urn, call_options, advanced_typecasting, log_enabled, log_level, cookies) ⇒ ClientWrapper
Returns a new instance of ClientWrapper.
3 4 5 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 |
# File 'lib/easy_upnp/control_point/client_wrapper.rb', line 3 def initialize(endpoint, urn, , advanced_typecasting, log_enabled, log_level, ) # For some reason was not able to pass these options in the config block # in Savon 2.11 = { log: log_enabled, log_level: log_level } @client = Savon.client() do |c| c.endpoint endpoint c.namespace urn # I found this was necessary on some of my UPnP devices (namely, a Sony TV). c.namespaces({:'s:encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"}) # This makes XML tags be like <ObjectID> instead of <objectID>. c.convert_request_keys_to :camelcase c.namespace_identifier :u c.env_namespace :s end @urn = urn @call_options = @advanced_typecasting = advanced_typecasting @cookies = end |
Instance Method Details
#call(action_name, args) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/easy_upnp/control_point/client_wrapper.rb', line 38 def call(action_name, args) attrs = { soap_action: "#{@urn}##{action_name}", attributes: { :'xmlns:u' => @urn }, }.merge(@call_options) if !@cookies.nil? attrs = attrs.merge( cookies: HTTPI::Cookie.new(@cookies) ) end advanced_typecasting = @advanced_typecasting response = @client.call(action_name, attrs) do advanced_typecasting advanced_typecasting (args) end end |