Class | DBus::RemoteObject |
In: |
lib/dbus.rb
|
Parent: | Object |
Represents a remote object.
A RemoteObject is provided by a RemoteService on a particular Bus. RemoteObjects have member functions, and can be called like normal Ruby objects.
# File lib/dbus.rb, line 153 153: def initialize(service, object_path, interface) 154: @service = service 155: @object_path = object_path 156: @interface = interface 157: end
Connect the signal signal_name on this remote object to the supplied handler proc handler_proc.
# File lib/dbus.rb, line 161 161: def connect_to_signal(signal_name, handler_proc) 162: @service.get_bus.add_signal_receiver(handler_proc, 163: signal_name, 164: @interface, 165: @service.get_service_name, 166: @object_path) 167: end
Implements magic remote method calls
# File lib/dbus.rb, line 170 170: def method_missing(sym, *args) 171: name = sym.id2name 172: message = DBus::Binding::DBusMessage.new_method_call(@service.get_service_name, 173: @object_path, 174: @interface, 175: name) 176: iter = message.get_iter 177: args.each{|a| iter.append(a)} 178: reply = @service.get_bus.get_connection.send_with_reply_and_block(message, 5000) 179: reply_args = reply.to_a 180: return nil if reply_args.empty? 181: return reply_args[0] if reply_args.length == 1 182: return reply_args 183: end