Class: RBus::Bus

Inherits:
Proxy show all
Defined in:
lib/rbus/bus/bus.rb

Overview

Represents a connection to a Bus. It is also a Proxy object for sending messages to the bus itself.

Direct Known Subclasses

SessionBus, SystemBus

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Proxy

#Introspect, #connect!, #interface!, #method!, #method_missing, #parse_arguments!, parse_introspect

Constructor Details

#initialize(server_address) ⇒ Bus

Connect to Bus with server_address, which can contain multiple addresses to try, separated by semicolons.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/rbus/bus/bus.rb', line 54

def initialize(server_address)
  raise InvalidAddressException, 'Empty address' if server_address.empty?

  # Can be several addresses, separated by ;
  server_address.split(';').each do |address|
    @transport = Transport.connect(address)
  end

  # Not used for anything, save at all?
  @guid = Auth.authorize(@transport)

  # Setup mainloop.
  @message_loop = Mainloop.new(self)
  
  @well_known_name = 'org.freedesktop.DBus'
  @object_path = '/org/freedesktop/DBus'
  @interface = 'org.freedesktop.DBus'
  @names = [ Hello() ]
  Introspect()

  Log.debug('Bus names:', @names)

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RBus::Proxy

Instance Attribute Details

#message_loopObject (readonly)

Returns the value of attribute message_loop.



50
51
52
# File 'lib/rbus/bus/bus.rb', line 50

def message_loop
  @message_loop
end

#namesObject (readonly)

Returns the value of attribute names.



50
51
52
# File 'lib/rbus/bus/bus.rb', line 50

def names
  @names
end

#transportObject (readonly)

Returns the value of attribute transport.



50
51
52
# File 'lib/rbus/bus/bus.rb', line 50

def transport
  @transport
end

Instance Method Details

#get_object(well_known_name, object_path) ⇒ Object

Returns a remote object for well-known name and object path.



79
80
81
# File 'lib/rbus/bus/bus.rb', line 79

def get_object(well_known_name, object_path)
  Proxy.new(self, well_known_name, object_path)
end