Protocol::DBus::Peer - base class for a D-Bus peer
$dbus->send_call( interface => 'org.freedesktop.DBus.Properties', member => 'GetAll', signature => 's', path => '/org/freedesktop/DBus', destination => 'org.freedesktop.DBus', body => [ 'org.freedesktop.DBus' ], on_return => sub { my ($msg) = @_ }, ); my $msg = $dbus->get_message(); # Same pattern as the IO::Handle method. $dbus->blocking(0); my $fileno = $dbus->fileno(); $dbus->flush_write_queue() if $dbus->pending_send(); # I’m not sure why you’d want to do this, but … $dbus->big_endian();
This class contains D-Bus logic that is useful in both client and server contexts. (Currently this distribution does not include a server implementation.)
This returns a single instace of Protocol::DBus::Message, or undef if no message is available. It will also fire the appropriate “on_return” method on METHOD_RETURN messages.
The backend I/O logic reads data in chunks; thus, if there is a message already available in the read buffer, no I/O is done. If you’re doing non-blocking I/O then it is thus vital that, every time the DBus socket is readable, you call this function until undef is returned.
Same as IO::Framed::Write’s method of the same name.
Send a METHOD_CALL message to the server.
%OPTS are path, interface, member, destination, signature, body, and on_return. These do as you’d expect, with the following caveats:
path
interface
member
destination
signature
body
on_return
body, if given, must be an array reference. See Protocol::DBus::Message for a discussion of how to map between D-Bus and Perl.
The on_return callback receives the server’s response message (NB: either METHOD_RETURN or ERROR) as argument.
Same interface as blocking(), but this sets/gets/toggles whether to send big-endian messages instead of little-endian.
blocking()
(I’m not sure why it would matter?)
Same interface as blocking(), but when this is enabled variants are given as two-member array references ([ signature => value ]), blessed as Protocol::DBus::Type::Variant instances.
Protocol::DBus::Type::Variant
For most Perl applications this is probably counterproductive.
Same interface as IO::Handle’s method of the same name.
Returns the connection socket’s file descriptor.
Returns a boolean that indicates whether there is data queued up to send to the server.
To install Protocol::DBus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Protocol::DBus
CPAN shell
perl -MCPAN -e shell install Protocol::DBus
For more information on module installation, please visit the detailed CPAN module installation guide.