omni::connect::core::LiveSessionChannel
Defined in omni/connect/core/LiveSessionChannel.h
Structs
-
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
andGetUsers
messages from other clients with aHello
message.This class does not run message processing in a dedicated thread, so
processMessages()
is is used to process theJoin
/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
orGetUsers
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.
-
enumerator eJoin
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
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.)
-
MessageType type
-
struct User
Live session channel user structure.
When a message is received this information will identify a client
-
enum class MessageType