Net::DBus::Object Methods

From AN!Wiki
Jump to: navigation, search

 AN!Tools :: Net::DBus Binding Tutorial :: Net::DBus::Object Methods

If the environment variable 'DBUS_DISABLE_INTROSPECT' is set, then introspection will be disabled.

The following methods are defined;

use Net::DBus::Exporter "org.freedesktop.DBus.Introspectable";
 
dbus_method("Introspect", [], ["string"]);
 
dbus_method("Get", ["string", "string"], [["variant"]], "org.freedesktop.DBus.Properties");
dbus_method("Set", ["string", "string", ["variant"]], [], "org.freedesktop.DBus.Properties");

Usage:

use Net::DBus;
my $bus=Net::DBus->find;
my $service=$bus->export_service("org.demo.Hello");

 

Contents

new

Usage:

my $path="/org/demo/SaySomething";
my $object=Net::DBus::Object->new($service, $path);

This creates a new '$object' registered withing the '$service' and available at the defined '$path'.

disconnect

Usage:

$object->disconnect();

This disconnects the '$object' and recursively disconnect all child objects from the message bus. This allows new objects to be connected in place of the disconnected one(s).

is_connected

Usage:

my $check_connection=$object->is_connected;

This simply checks if the '$object' is still connected to the message bus. It returns '1' if it is, '0' if not.

get_service

Usage:

my $service=$object->get_service

This returns the 'Net::DBus::Service' '$service' handle that this object is exported under.

get_object_path

Usage:

my $path=$object->get_object_path;

This returns the '$path' name used to export the $object.

emit_signal_in

my $name="Greeter";                       # The name of the method.
my $interface="org.example.demo.Greeter"; # If set, the signal will be emitted only within this interface.
my $client="";                            # If set, the signal will be emitted only to this client.
my @args=("Just saying hello.");          # This must match the arguments defined when 'dbus_signal' was called for this signal.
$object->emit_signal_in($name, $interface, $client, @args);

This emits a signal from the $object's method named '$name'. Optionally, you can specify an '$interface' to emit the signal within. Also optionally, you can specify a '$client' to have the signal unicast to.

This method must have been previously exported using the Net::DBus::Exporter->dbus_signal method.

emit_signal_to

Usage:

my $name="Greeter";                       # The name of the method.
my $client="";                            # The client whom the signal will be emitted to.
my @args=("Just saying hello.");          # This must match the arguments defined when 'dbus_signal' was called for this signal.
$object->emit_signal_to($name, $client, @args);

Like the 'emit_signal_in' method, this emits a signal. However, this method will explicitely emit a signal to the specified '$client'. You can not use this method if a given signal is available on more than one interface. In this case, use 'emit_signal_in' with a defined interface instead.

emit_signal

Usage:

my $name="Greeter";                       # The name of the method.
my @args=("Just saying hello.");          # This must match the arguments defined when 'dbus_signal' was called for this signal.
$object->emit_signal($name, @args);

This method emits a signal from the $object's method with the given '$name'. Unlike 'emit_signal_to', no specific interface can be defined. Also, unlike either 'emit_signal_in' or 'emit_signal_in', no specific client can be defined.

connect_to_signal_in

Usage:

my $name="Greeter";                       # The name of the method.
my $interface="org.example.demo.Greeter"; # If set, the signal will be emitted only within this interface.
$object->connect_to_signal_in($name, $interface, \&some_function);

This connects a subroutine to the object '$object' that is called whenever the signal with the given '$name' is emitted. The code referenced is passed the data emitted by the signal. You can define the '$interface' to use when there are more than one interface with a signal of the given name.

connect_to_signal

Usage:

my $name="Greeter";                       # The name of the method.
$object->connect_to_signal($name, \&some_function);

This connects a subroutine to the object '$object' that is called whenever the signal with the given '$name' is emitted. The code referenced is passed the data emitted by the signal. This method does not allow an interface to be defined, and this can not be used when multiple interfaces in the '$object' share the same signal name.

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Us: Alteeve's Niche! Support: Mailing List IRC: #clusterlabs on Freenode   © Alteeve's Niche! Inc. 1997-2019
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.
Personal tools
Namespaces

Variants
Actions
Navigation
projects
Toolbox