Class Bus
java.lang.Object
lol.trq.orpheus.linux.dbus.Bus
- All Implemented Interfaces:
AutoCloseable
A connection to a D-Bus message bus: authentication, sending, and one reader thread that completes method calls
and hands every other message to a listener. Small on purpose: only what talking to media players needs.
-
Method Summary
-
Method Details
-
connect
public static Bus connect(String socketPath, Consumer<Message> listener, Runnable onClose) throws IOException Opens a Unix socket, authenticates as the current user and starts reading.- Parameters:
socketPath- the bus socketlistener- receives signals and incoming method calls, on the reader threadonClose- runs once, on the reader thread, when the connection ends for any reason butclose()- Throws:
IOException
-
send
Sends a message without waiting for anything.- Throws:
IOException
-
call
Sends a method call. The future completes with the reply, which may be an error reply, or fails when the connection ends first. It never completes on its own if the peer stays silent: callers add a timeout. -
close
public void close()Closes the connection, fails calls still waiting and stops the reader thread.- Specified by:
closein interfaceAutoCloseable
-