class GxG::Networking::XmlrpcClient
XMLRPC Classes:
Public Class Methods
new()
click to toggle source
# File lib/gxg/net_clients.rb, line 2341 def initialize() @client = nil @interface = nil self end
Public Instance Methods
callmethod(the_method = nil, arguments = nil)
click to toggle source
# File lib/gxg/net_clients.rb, line 2404 def callmethod(the_method = nil, arguments = nil) # The +method+ parameter is converted into a String and should # be a valid XML-RPC method-name. # # Each parameter of +args+ must be of one of the following types, # where Hash, Struct and Array can contain any of these listed _types_: # # * Fixnum, Bignum # * TrueClass, FalseClass, +true+, +false+ # * String, Symbol # * Float # * Hash, Struct # * Array # * Date, Time, XMLRPC::DateTime # * XMLRPC::Base64 # * A Ruby object which class includes XMLRPC::Marshallable # (only if Config::ENABLE_MARSHALLABLE is +true+). # That object is converted into a hash, with one additional key/value # pair <code>___class___</code> which contains the class name # for restoring that object later. result = nil begin unless the_method.is_a?(::String) raise ArgumentError, "You MUST provide a valid method String." end if @client calldata = [] calldata << the_method # # TODO: scour arguments structure for type conversions to be done. if arguments.is_a?(::Array) arguments.each do |entry| calldata << entry end else if arguments calldata << arguments end end result = @client.call(*calldata) # TODO: scour result structure for type conversions to gxg standard. end rescue Exception => the_error log_error({:error => the_error, :parameters => {:method => the_method, :arguments => arguments}}) end result end
closed?()
click to toggle source
# File lib/gxg/net_clients.rb, line 2396 def closed?() if @client false else true end end
interface()
click to toggle source
# File lib/gxg/net_clients.rb, line 2452 def interface() begin if @client unless @interface @interface = @client.call("interface") end unless @interface @interface = @client.call("Interface") end end rescue Exception => the_error # log_error({:error => the_error, :parameters => {}}) end @interface end
login(the_url=nil, options={})
click to toggle source
# File lib/gxg/net_clients.rb, line 2347 def login(the_url=nil, options={}) result = false begin unless the_url.is_a?(::URI::Generic) raise ArgumentError, "You MUST provide a valid URI." end if options[:use_ssl] == true || the_url.scheme.to_s.downcase == 'https' client_parameters = [(the_url.hostname), (the_url.path), (the_url.port || 443)] else client_parameters = [(the_url.hostname), (the_url.path), (the_url.port || 80)] end if options[:proxy].is_a?(::URI::Generic) client_parameters << options[:proxy].host client_parameters << options[:proxy].port else client_parameters << nil client_parameters << nil end if the_url.user && the_url.password client_parameters << the_url.user client_parameters << the_url.password else client_parameters << nil client_parameters << nil end if options[:use_ssl] == true || the_url.scheme.to_s.downcase == 'https' client_parameters << true else client_parameters << nil end if options[:timeout].is_a?(::Numeric) client_parameters << options[:timeout].to_i else client_parameters << 30 end @client = ::XMLRPC::Client.new(*client_parameters) this().interface() result = true rescue Exception => the_error log_error({:error => the_error, :parameters => {:url => the_url}}) end result end
logout()
click to toggle source
# File lib/gxg/net_clients.rb, line 2391 def logout() @client = nil true end