Message

class dbus_next.Message(destination: Optional[str] = None, path: Optional[str] = None, interface: Optional[str] = None, member: Optional[str] = None, message_type: dbus_next.constants.MessageType = <MessageType.METHOD_CALL: 1>, flags: dbus_next.constants.MessageFlag = <MessageFlag.NONE: 0>, error_name: Optional[str] = None, reply_serial: Optional[int] = None, sender: Optional[str] = None, unix_fds: List[int] = [], signature: str = '', body: List[Any] = [], serial: int = 0)

A class for sending and receiving messages through the MessageBus with the low-level api.

A Message can be constructed by the user to send over the message bus. When messages are received, such as from method calls or signal emissions, they will use this class as well.

Variables
  • destination (str) – The address of the client for which this message is intended.

  • path (str) – The intended object path exported on the destination bus.

  • interface (str) – The intended interface on the object path.

  • member (str) – The intended member on the interface.

  • message_type (MessageType) – The type of this message. A method call, signal, method return, or error.

  • flags (MessageFlag) – Flags that affect the behavior of this message.

  • error_name (str) – If this message is an error, the name of this error. Must be a valid interface name.

  • reply_serial (int) – If this is a return type, the serial this message is in reply to.

  • sender (str) – The address of the sender of this message. Will be a unique name.

  • unix_fds (list(int)) – A list of unix fds that were sent in the header of this message.

  • signature (str) – The signature of the body of this message.

  • signature_tree (SignatureTree) – The signature parsed as a signature tree.

  • body (list(Any)) – The body of this message. Must match the signature.

  • serial (int) – The serial of the message. Will be automatically set during message sending if not present. Use the new_serial() method of the bus to generate a serial.

Raises
static new_error(msg: dbus_next.message.Message, error_name: str, error_text: str)dbus_next.message.Message

A convenience constructor to create an error message in reply to the given message.

Parameters
  • msg (Message) – The message this error is in reply to.

  • error_name (str) – The name of this error. Must be a valid interface name.

  • error_text – Human-readable text for the error.

Returns

The error message.

Return type

Message

Raises
static new_method_return(msg: dbus_next.message.Message, signature: str = '', body: List[Any] = [], unix_fds: List[int] = [])dbus_next.message.Message

A convenience constructor to create a method return to the given method call message.

Parameters
  • msg (Message) – The method call message this is a reply to.

  • signature (str) – The signature for the message body.

  • body (list(int)) – The body of this message. Must match the signature.

  • unix_fds – List integer file descriptors to send with this message.

Returns

The method return message

Return type

Message

Raises
static new_signal(path: str, interface: str, member: str, signature: str = '', body: Optional[List[Any]] = None, unix_fds: Optional[List[int]] = None)dbus_next.message.Message

A convenience constructor to create a new signal message.

Parameters
  • path (str) – The path of this signal.

  • interface (str) – The interface of this signal.

  • member (str) – The member name of this signal.

  • signature (str) – The signature of the signal body.

  • body (list(int)) – The body of this signal message.

  • unix_fds – List integer file descriptors to send with this message.

Returns

The signal message.

Return type

Message

Raises