Net::DBus::Object(3)
π NAME π
okay so bestie, this is Net::DBus::Object(3) from the User Contributed Perl Documentation, and it's literally the base for implementing objects to export to the bus. That's the name: Net::DBus::Object β implement objects to export to the bus. iconic. π¦
β¨ SYNOPSIS β¨
here's the whole demo, bestie β code kept exactly as it should be, no edits, no cap:
# Connecting an object to the bus, under a service
package main;
use Net::DBus;
# Attach to the bus
my $bus = Net::DBus->find;
# Acquire a service 'org.demo.Hello'
my $service = $bus->export_service("org.demo.Hello");
# Export our object within the service
my $object = Demo::HelloWorld->new($service);
....rest of program...
# Define a new package for the object we're going
# to export
package Demo::HelloWorld;
# Specify the main interface provided by our object
use Net::DBus::Exporter qw(org.example.demo.Greeter);
# We're going to be a DBus object
use base qw(Net::DBus::Object);
# Export a 'Greeting' signal taking a stringl string parameter
dbus_signal("Greeting", ["string"]);
# Export 'Hello' as a method accepting a single string
# parameter, and returning a single string value
dbus_method("Hello", ["string"], ["string"]);
sub new {
my $class = shift;
my $service = shift;
my $self = $class->SUPER::new($service, "/org/demo/HelloWorld");
bless $self, $class;
return $self;
}
sub Hello {
my $self = shift;
my $name = shift;
$self->emit_signal("Greeting", "Hello $name");
return "Said hello to $name";
}
# Export 'Goodbye' as a method accepting a single string
# parameter, and returning a single string, but put it
# in the 'org.exaple.demo.Farewell' interface
dbus_method("Goodbye", ["string"], ["string"], "org.example.demo.Farewell");
sub Goodbye {
my $self = shift;
my $name = shift;
$self->emit_signal("Greeting", "Goodbye $name");
return "Said goodbye to $name";
}
okay so that's the vibe: attach to the bus, acquire service 'org.demo.Hello', export Demo::HelloWorld, define the package, specify the main interface, inherit from Net::DBus::Object, export a Greeting signal, export Hello and Goodbye methods, and make them emit signals and return strings. all there. π
πΈ DESCRIPTION πΈ
This is the base for implementing objects which are directly exported to the bus. The methods implemented in a subclass are mapped to methods on the bus. By using this class, an application is directly tieing the RPC functionality into its object model. Because of that, applications may thus prefer to use the Net::DBus::ProxyObject class, which allows the RPC functionality to be maintained separately from the core object model, by proxying RPC method calls. lowkey the flexible route, iykyk π
π METHODS π
my $object = Net::DBus::Object->new($service, $path)β creates a new DBus object with path$pathregistered within the service$service. The$pathparameter should be a string complying with the usual DBus requirements for object paths, while the$serviceparameter should be an instance ofNet::DBus::Service. The latter is typically obtained by calling theexport_servicemethod on theNet::DBusobject. π«Άmy $object = Net::DBus::Object->new($parentobj, $subpath)β creates a new DBus child object with path$subpathrelative to its parent$parentobj. The$subpathparameter should be a string complying with the usual DBus requirements for object paths, while the$parentobjparameter should be an instance ofNet::DBus::BaseObjector a subclass. π§
π AUTHOR π
Daniel P. Berrange. periodt. π
π COPYRIGHT π
Copyright (C) 2005-2011 Daniel P. Berrange. that's the line, bestie.
π SEE ALSO π
Net::DBusNet::DBus::ServiceNet::DBus::BaseObjectNet::DBus::ProxyObjectNet::DBus::ExporterNet::DBus::RemoteObject
okay that's the whole page, bestie β this is Net::DBus::Object(3) from perl v5.42.0, dated 2019-12-17. go export something iconic π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- opensuse-leap 16.0: perl-Net-DBus 1.2.0-160000.2.2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms