Net::DB...yObject(3)
π Net::DBus::ProxyObject(3) β the glow-up guide π
okay bestie, so like... this is the manual page for Net::DBus::ProxyObject from the User Contributed Perl Documentation. it's giving "I make DBus objects talk to your app objects" and honestly? iconic. let's get into it β¨
πΈ NAME πΈ
Net::DBus::ProxyObject β literally the module that lets you implement objects and yeet them onto the bus. no cap, that's the whole vibe π«Ά
π¦ SYNOPSIS π¦
bestie, here's the entire example code, and I mean entire. do not skip it, it's all doing something, iykyk π
# Connecting an object to the bus, under a service
package main;
use Net::DBus;
# Attach to the bus
my $bus = Net::DBus->find;
# Create our application's object instance
my $object = Demo::HelloWorld->new()
# Acquire a service 'org.demo.Hello'
my $service = $bus->export_service("org.demo.Hello");
# Finally export the object to the bus
my $proxy = Demo::HelloWorld::DBus->new($object);
....rest of program...
# Define a new package for the object we're going
# to export
package Demo::HelloWorld;
sub new {
my $class = shift;
my $service = shift;
my $self = {};
$self->{sighandler} = undef;
bless $self, $class;
return $self;
}
sub sighandler {
my $self = shift;
my $callback = shift;
$self->[sighandler} = $callback;
}
sub Hello {
my $self = shift;
my $name = shift;
&{$self->{sighandler}}("Greeting", "Hello $name");
return "Said hello to $name";
}
sub Goodbye {
my $self = shift;
my $name = shift;
&{$self->{sighandler}}("Greeting", "Goodbye $name");
return "Said goodbye to $name";
}
# Define a new package for the object we're going
# to export
package Demo::HelloWorld::DBus;
# 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::ProxyObject);
# 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 $impl = shfit;
my $self = $class->SUPER::new($service, "/org/demo/HelloWorld", $impl);
bless $self, $class;
$self->sighandler(sub {
my $signame = shift;
my $arg = shift;
$self->emit_signal($signame, $arg);
});
return $self;
}
# 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");
no notes, the comments in there are doing the heavy lifting anyway π
π DESCRIPTION π
okay so picture this: you've got your application's object model, and you've got the RPC object model, and they should not be forced to mingle. that's where this module comes in, it's literally the base class for creating a proxy between a bus object and your application's object. main character energy, honestly.
the proxy object's whole job is to forward method calls from the bus straight over to the implementation object. like a little messenger π§ and on top of that, the proxy object can register callbacks against the application object, which it can then use to emit signals back out onto the bus. slay π
β¨ METHODS β¨
π my $object = Net::DBus::ProxyObject->new($service, $path, $impl)
this one creates a brand-new DBus object, with a path of $path registered inside the service $service. bestie, keep in mind:
- the
$pathparameter should be a string complying with the usual DBus requirements for object paths. - the
$serviceparameter should be an instance ofNet::DBus::Service. - the
$serviceis typically obtained by calling the"export_service"method on theNet::DBusobject. - the
$implparameter is the application object which will implement the methods being exported to the bus.
like, that's the whole og constructor, no cap π«Ά
π¦ my $object = Net::DBus::ProxyObject->new($parentobj, $subpath, $impl)
this one is the child object spawner, lowkey my fave. it creates a new DBus child object with a path of $subpath relative to its parent $parentobj. the deets:
- the
$subpathparameter should be a string complying with the usual DBus requirements for object paths. - the
$parentobjparameter should be an instance ofNet::DBus::BaseObjector a subclass. - the
$implparameter is the application object which will implement the methods being exported to the bus.
literally the same energy, just nested family vibes π
π AUTHOR π
Daniel P. Berrange β the icon behind all this, periodt π
π COPYRIGHT π
Copyright (C) 2005-2011 Daniel P. Berrange β handing out copyright like it's going out of style (it's not) π
π₯ SEE ALSO π₯
bestie, if you liked this one, go read its friends, they're all linked up:
Net::DBusNet::DBus::ServiceNet::DBus::BaseObjectNet::DBus::ProxyObjectNet::DBus::ExporterNet::DBus::RemoteObject
okay that's the whole page, you're officially smarter than like 90% of people now ππ
and that's a wrap! this documentation came from perl v5.42.0, dated 2019-12-17 β like, vintage but still serving looks πΈβ¨ go forth and proxy, bestie π«Ά
π¦ 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