join_channel_async#

async omni.kit.collaboration.channel_manager.join_channel_async(
url: str,
get_users_only=False,
) Channel#

Joins a channel and starts listening. The typical life cycle is as follows of a channel session if get_users_only is False: 1. User joins and sends a JOIN message to the channel. 2. Other clients receive JOIN message will respond with HELLO to broadcast its existence. 3. Clients communicate with each other by sending MESSAGE to each other. 4. Clients send LEFT before quit this channel.

Parameters:
  • url (str) – The channel url to join. The url could be stage url or url with `.__omni_channel__` or `.channel` suffix. If the suffix is not provided, it will be appended internally with `.__omni_channel__` to be compatible with old version.

  • get_users_only (bool) – It will join channel without sending JOIN/HELLO/LEFT message but only receives message from other clients. For example, it can be used to fetch user list without broadcasting its existence. After joining, all users inside the channel will respond HELLO message.

Returns:

omni.kit.collaboration.channel_manager.Channel. The instance of channel that could be used to publish/subscribe channel messages.

Examples

>>> import omni.kit.collaboration.channel_manager as nm
>>>
>>> async join_channel_async(url):
>>>     channel = await nm.join_channel_async(url)
>>>     if channel:
>>>         channel.add_subscriber(...)
>>>         await channel.send_message_async(...)
>>>     else:
>>>         # Failed to join
>>>         pass