pyrtma.client.Client
- class Client(module_id=0, host_id=0, timecode=False, name='')[source]
Bases:
ClientLikeRTMA Client interface
- Parameters:
Methods
Connect to message manager server
Read and discard messages in socket buffer up to timeout
Disconnect from message manager server
Forward a message
Pause all subscribed types
Pause subscription to message types
Context manager to pause subscriptions to a list of message types
Read a message
Unsubscribe from all messages and empty the message buffer.
Resume all paused subscriptions
Resume subscription to message types
Send a message
Send a signal to message manager that client is ready
Send a signal
Subscribe to message types
Context manager to subscribe to a list of message types
Unsubscribe from message types
Unsubscribe from all subscribed types
Attributes
Status of connection to message manager server
Class defining the RTMA message header
Message manager IP address string
log_levelloggerNumeric module ID of client
Count of messages that have been sent
nameSubscriptions on pause
Message manager port number
Message manager server address as a (IP_addr, port_num) tuple
Underlying socket connection with MessageManager
List of subscribed message types
- connect(server_name='localhost:7111', logger_status=False, daemon_status=False, allow_multiple=False)[source]
Connect to message manager server
- Parameters:
server_name (
str) – IP_addr:port_num string associated with message manager. Defaults to “localhost:7111”.logger_status (
bool) – Flag to declare client as a logger module. Logger modules are automatically subscribed to all message types. Defaults to False.allow_multiple (
bool) – Flag to declare client can have multiple instances. Defaults to False.daemon_status (bool)
- Raises:
MessageManagerNotFound – Unable to connect to message manager
- forward_message(msg_hdr, msg_data=None, timeout=-1)[source]
Forward a message
A message is a packet that contains a defined data payload. To send a message without associated data, see
send_signal().- Parameters:
msg_hdr (
MessageHeader) – Object containing RTMA header to sendmsg_data (
MessageData|None) – Object containing the message to sendtimeout (
float) – Timeout in seconds to wait for socket to be available for sending. Defaults to -1 (blocking).
- property header_cls: Type[MessageHeader]
Class defining the RTMA message header
- paused_subscription_context(msg_list)[source]
Context manager to pause subscriptions to a list of message types
Message types will automatically resume subscriptions after exiting context.
- read_message(timeout=-1, ack=False, sync_check=False)[source]
Read a message
- Parameters:
timeout (
int|float|None) – Timeout to wait for a message to be available for reading. Defaults to -1 (blocking).ack (optional) – Primarily for internal use. When True, will not discard ACK messages. Defaults to False.
sync_check (optional) – Validate message definition matches header version. Defaults to False.
- Raises:
ConnectionLost – Connection error to message manager server
- Return type:
- Returns:
Message object. If no message is read before timeout, returns None.
- reset_subscriptions(subscribe_list=None)[source]
Unsubscribe from all messages and empty the message buffer. If optional ‘subscribe_list’ argument given, then will subscribe to new messages after reset.
- send_message(msg_data, dest_mod_id=0, dest_host_id=0, timeout=-1)[source]
Send a message
A message is a packet that contains a defined data payload. To send a message without associated data, see
send_signal().- Parameters:
msg_data (
MessageData) – Object containing the message to senddest_mod_id (
int) – Specific module ID to send to. Defaults to 0 (broadcast).dest_host_id (
int) – Specific host ID to send to. Defaults to 0 (broadcast).timeout (
float) – Timeout in seconds to wait for socket to be available for sending. Defaults to -1 (blocking).
- Raises:
InvalidDestinationModule – Specified destination module is invalid
InvalidDestinationHost – Specified destination host is invalid
- send_module_ready()[source]
Send a signal to message manager that client is ready
This method also sends the client’s process ID to message manager.
- send_signal(signal_type, dest_mod_id=0, dest_host_id=0, timeout=-1)[source]
Send a signal
A signal is a message type without an associated data payload. Only a unique message type ID is required to send a signal. To send a message with data, see
send_message().- Parameters:
signal_type (
int) – Numeric message type ID of signaldest_mod_id (
int) – Specific module ID to send to. Defaults to 0 (broadcast).dest_host_id (
int) – Specific host ID to send to. Defaults to 0 (broadcast).timeout (
float) – Timeout in seconds to wait for socket to be available for sending. Defaults to -1 (blocking).
- Raises:
InvalidDestinationModule – Specified destination module is invalid
InvalidDestinationHost – Specified destination host is invalid
- subscribe(msg_list)[source]
Subscribe to message types
Calling this method multiple times will add to, and not replace, the list of subscribed messages.
- subscription_context(msg_list)[source]
Context manager to subscribe to a list of message types
Message types will automatically unsubscribe after exiting context.