LivestreamMessaging#

class omni.kit.livestream.messaging.LivestreamMessaging#

Bases: IExt

Methods

__init__(self)

clear_event_types_to_send()

Unregisters all event types currently being monitored for sending or observing.

observe(event_name)

Decorator to observe an event and register a handler function.

observe_and_dispatch(event_name[, response_name])

Decorator to observe an event and automatically dispatch a response event.

on_shutdown()

Cleans up resources and unsubscribes from all events when the extension is shut down.

on_startup()

Initializes the extension and sets up event subscriptions.

register_event_type_to_send(event_name)

Registers an event name to monitor for outgoing messages to the client.

unregister_event_type_to_send(event_name)

Unregisters an event name to stop monitoring and sending messages for it.

unregister_observe_type(event_name)

Unregisters an event name to stop observing and receiving events for it.

Attributes

instance

__init__(self: omni.ext._extensions.IExt) None#
clear_event_types_to_send()#

Unregisters all event types currently being monitored for sending or observing.

Iterates through all registered dispatch and observe event names, removing their subscriptions and cleaning up internal tracking. Ensures that no events are left being monitored for sending or receiving.

observe(event_name: str) Callable#

Decorator to observe an event and register a handler function.

Registers the decorated function as an event handler for the specified event_name using carb.eventdispatcher. When the event is received, the handler is called with the event object.

Parameters:

event_name (str) – The name of the event to observe.

Returns:

The decorator that registers the handler function.

Return type:

Callable

observe_and_dispatch(
event_name: str,
response_name: str = '',
) Callable#

Decorator to observe an event and automatically dispatch a response event.

Registers the decorated function as an event handler for the specified event_name using carb.eventdispatcher. When the event is received, the handler is called with the event and its payload unpacked as keyword arguments. The return value of the handler is sent as a response event to response_name (or to “{event_name}:response” if not specified), including the original event id if present.

Parameters:
  • event_name (str) – The name of the event to observe.

  • response_name (str, optional) – The name of the response event to dispatch. If not provided, defaults to “{event_name}:response”.

Returns:

The decorator that registers the handler.

Return type:

Callable

on_shutdown()#

Cleans up resources and unsubscribes from all events when the extension is shut down.

Unregisters all event types being monitored for observing and dispatching, releases the unique sender ID, and resets the singleton instance.

on_startup()#

Initializes the extension and sets up event subscriptions.

Acquires a unique sender ID, registers the receive message event alias for backward compatibility, and subscribes to the receive message event using carb.eventdispatcher. Sets the singleton instance for the extension.

register_event_type_to_send(event_name: str)#

Registers an event name to monitor for outgoing messages to the client.

Sets up an event alias for backward compatibility and subscribes to the specified event using carb.eventdispatcher. When the event is triggered, the _on_message_to_send handler is called to process and forward the message.

Parameters:

event_name (str) – The name of the event to register for sending messages.

unregister_event_type_to_send(event_name: str)#

Unregisters an event name to stop monitoring and sending messages for it.

Removes the event subscription and alias for the specified event_name, ensuring that messages are no longer sent for this event. Cleans up internal tracking dictionaries.

Parameters:

event_name (str) – The name of the event to unregister.

unregister_observe_type(event_name: str) None#

Unregisters an event name to stop observing and receiving events for it.

Removes the event subscription for the specified event_name, ensuring that the handler is no longer called when the event is received. Cleans up internal tracking.

Parameters:

event_name (str) – The name of the event to stop observing.