LiveSessionComboBoxModel#

class omni.kit.widget.live_session_management_ui.LiveSessionComboBoxModel(
layer_identifier: str,
get_current_live_session_cb: Callable[[str], LiveSessionInterface],
get_all_live_sessions_cb: Callable[[str], List[LiveSessionInterface]],
update_users: bool = True,
)#

Bases: AbstractItemModel

A combo box model for managing live session selection and user tracking.

This class provides a UI model for displaying and managing live collaboration sessions in a combo box widget. It handles session selection, user presence tracking, and maintains communication with collaboration channels for real-time updates.

The model automatically sorts sessions with the default session appearing first, followed by other sessions ordered by last modified time. It tracks the currently selected session and maintains a list of all users participating in the selected session.

Parameters:
  • layer_identifier (str) – Unique identifier for the base layer.

  • get_current_live_session_cb (Callable[[str], LiveSessionInterface]) – Callback function to retrieve the current live session for a given identifier.

  • get_all_live_sessions_cb (Callable[[str], List[LiveSessionInterface]]) – Callback function to retrieve all available live sessions for a given identifier.

  • update_users (bool) – Whether to track and update user presence information. Defaults to True.

Methods

__init__(layer_identifier, ...[, update_users])

Initializes the LiveSessionComboBoxModel with layer identifier, session callbacks, and optional user updates.

add_value_changed(fn)

Adds a callback function to be invoked when the current session selection changes.

clear()

Clears all session items and resets the current session selection.

create_new_session_name()

Empty by default

destroy()

Destroys the model and releases all resources including callbacks and channel connections.

empty()

Checks if the model contains any session items.

get_item_children(item)

Gets the child items for the specified parent item.

get_item_value_model(item, column_id)

Gets the value model for the specified item and column.

refresh_sessions([force])

Refreshes the session list from the live session providers and updates the selection.

select_default_session()

Selects the default session if available.

set_model_reset_callback(callback)

Sets the callback function to be called when the model is reset.

set_user_update_callback(callback)

Sets the callback function to be called when users are updated.

stop_channel()

Stops the current channel connection and cancels any ongoing tasks.

Attributes

all_users

Gets all users currently in the live session.

base_layer_identifier

Gets the base layer identifier used for this model.

current_session

Gets the currently selected live session.

is_default_session_selected

Gets whether the default session is currently selected.

__init__(
layer_identifier: str,
get_current_live_session_cb: Callable[[str], LiveSessionInterface],
get_all_live_sessions_cb: Callable[[str], List[LiveSessionInterface]],
update_users: bool = True,
) None#

Initializes the LiveSessionComboBoxModel with layer identifier, session callbacks, and optional user updates.

add_value_changed(fn)#

Adds a callback function to be invoked when the current session selection changes.

Parameters:

fn (Callable) – Callback function to add for value change notifications.

clear()#

Clears all session items and resets the current session selection.

create_new_session_name() str#

Empty by default

Returns:

Empty string as the default session name.

Return type:

str

destroy()#

Destroys the model and releases all resources including callbacks and channel connections.

empty()#

Checks if the model contains any session items.

Returns:

True if no session items exist, False otherwise.

Return type:

bool

get_item_children(item)#

Gets the child items for the specified parent item.

Parameters:

item (ui.AbstractItem) – Parent item to retrieve children for.

Returns:

List of session items.

Return type:

List[LiveSessionComboBoxItem]

get_item_value_model(item, column_id)#

Gets the value model for the specified item and column.

Parameters:
  • item (ui.AbstractItem) – Item to get the value model for, or None for the current selection.

  • column_id (int) – Column identifier for the value model.

Returns:

The value model for the item or current index model if item is None.

Return type:

ui.AbstractValueModel

refresh_sessions(force=False)#

Refreshes the session list from the live session providers and updates the selection.

Parameters:

force (bool) – Whether to force refresh even if the index hasn’t changed.

select_default_session()#

Selects the default session if available.

Sets the current index to 0 to select the default session from the live sessions list.

set_model_reset_callback(
callback: Callable[[], None],
)#

Sets the callback function to be called when the model is reset.

Parameters:

callback (Callable[[], None]) – Function to call on model reset.

set_user_update_callback(
callback: Callable[[], None],
)#

Sets the callback function to be called when users are updated.

Parameters:

callback (Callable[[], None]) – Function to call on user updates.

stop_channel()#

Stops the current channel connection and cancels any ongoing tasks.

property all_users#

Gets all users currently in the live session.

Returns:

Dictionary of user IDs to user objects.

Return type:

dict

property base_layer_identifier#

Gets the base layer identifier used for this model.

Returns:

The base layer identifier.

Return type:

str

property current_session#

Gets the currently selected live session.

Returns:

The current session or None if no session is selected.

Return type:

LiveSessionInterface

property is_default_session_selected#

Gets whether the default session is currently selected.

Returns:

True if the default session is selected, False otherwise.

Return type:

bool