omni::connect::core::LiveSessionChannel

Defined in omni/connect/core/LiveSessionChannel.h

Structs

Message

Live session channel message structure.

User

Live session channel user structure.

class LiveSessionChannel

An interface class for the live session message channel.

The channel class implementation handles interaction with an Omniverse Nucleus channel, which is a mechanism to broadcast messages to all connected clients. When messages are received it will queue them, allowing the client to poll for them any time. When messages that specifically identify connected users are received, this class will maintain a list of connected users which the client can also poll.

This class also has a state machine that will automatically respond to Join and GetUsers messages from other clients with a Hello message.

This class does not run message processing in a dedicated thread, so processMessages() is is used to process the Join/Hello state machine and populate the user list.

Note

The static factory method create() returns a std::shared_ptr so object lifetime is managed by scope.

Public Types

enum class MessageType

Live session channel message types.

Values:

enumerator eJoin

Sent by the Channel class when joining a channel.

enumerator eHello

Sent as a response when another client sends a Join or GetUsers message.

enumerator eGetUsers

Sent by a client to determine what users are in the session.

enumerator eLeft

Sent when the user leaves the channel.

enumerator eMergeStarted

Sent when the Admin client is starting the merge process. When clients receive this message they should immediately disable further changes to the .live layer.

enumerator eMergeFinished

Sent when the merge is complete.

enumerator eInvalid

Invalid message.

using Messages = std::vector<Message>

A list of channel messages.

using Users = std::vector<User>

A list of channel users.

Public Functions

~LiveSessionChannel()
bool isConnected() const

Check if the channel is connected to an actual Nucleus channel file.

Returns

Whether the channel is connected

bool sendMessage(MessageType messageType) const

Send a channel message.

Parameters

messageType – The type of message to send

Returns

Whether the message was sent correctly

Messages processMessages()

Process and retrieve all of the pending channel messages.

This function drives the state machine that responds to other clients and populates the connected users list. It must be run periodically.

Note

It is safe to call this function from multiple threads simultaneously, the internal user and message queues are protected by mutexes.

Returns

A list of received messages

Users getUsers(bool includeSelf) const

Get all of the connected users.

Parameters

includeSelf – Whether to include this client user in list

Returns

A list of connected users

User getUser() const

Get this client user.

Returns

This client user

void leaveChannel()

Leave the channel.

This function will only send a “Left” message if sendJoinMessage was true in create()

Public Static Functions

static std::shared_ptr<LiveSessionChannel> create(const std::string &uri, bool sendJoinMessage = true)

Create and join an Omniverse live session message channel.

This is a factory to create and join a LiveSessionChannel. There is no join() method.

Note

Call omni::connect::core::startup() before this function to initialize required components

Parameters
  • uri – The URI of the Nucleus channel (session.channel)

  • sendJoinMessage – If true a Join message will be broadcast on the channel. Use false to “peek” into a channel to see connected users.

Returns

A channel interface shared pointer (std::shared_ptr<LiveSessionChannel>)

static const char *getMessageTypeName(LiveSessionChannel::MessageType messageType)

Convert a live session channel message type to a string.

Parameters

messageType – The type of message to convert to a string

Returns

A string value for the message type

struct Message

Live session channel message structure.

This consists of all of the data that a live session message contains (message type and sending user)

Public Members

MessageType type

The message type (Join, Left, MergeStarted, etc.)

User user

The user that sent the message.

struct User

Live session channel user structure.

When a message is received this information will identify a client

Public Members

std::string id

The user ID assigned by the Omniverse Client Library, eg. WD34WRMUJHLU7Q1M

std::string name

The user name used to connect to the Nucleus server.

std::string app

The name of the application used to connect to live session.