3.5. The Teleport Client library

3.5.1. Introduction

TeleportClient is a library that provides client functionality, in particular client-specific networking and object management.

3.5.2. Tab Context

A TabContext is created for each connection. A TabContext is like a tab in a web browser, it can connect to a server, thus initializing a session. A TabContext can only be permanently maintain a single connection, but in transitioning it can have two connections: the existing connection that has already been established, and the new one that should replace it.

flowchart TD subgraph "TabContext 1" A[Connection A] --> B[Connection B] end subgraph "TabContext 2" C[Connection C] end subgraph "TabContext 3" D[Connection D] --> E[Connection E] end

class TabContext

A “tab” in the Teleport client represents an ongoing connection to a single server The tab manages sessionClient creation/destruction. The tab may retain a temporary connection to an outgoing server while a new connection is established.

Public Functions

void ConnectionComplete(avs::uid uid)

Communication from SessionClient.

bool IsInUse() const

Is the tabContext connected or connecting? If not, it’s available for a connection.

3.5.3. Session Client

When a connection is made, a SessionClient is created to manage it. The SessionClient has a state that should progress as follows:

flowchart TD UNCONNECTED -- "User initiates connection" --> OFFERING OFFERING -- "User initiates connection" --> AWAITING_SETUP AWAITING_SETUP --> HANDSHAKING HANDSHAKING --> CONNECTED

The SessionClient class is:

class SessionClient : public avs::GenericTargetInterface

Public Functions

void ApplySetup(const teleport::core::SetupCommand &s)

For use only internally or by Renderer for the local session.

ConnectionStatus GetConnectionStatus() const

Returns the current connection status as determined by the signaling.

Returns:

bool IsReadyToRender() const

Is this client ready to render, i.e. does it have the final setup from the server required to initialize rendering? return true if ready, false if not.

inline AvatarManager &GetAvatarManager()

Avatar-negotiation state for this server. The host application sets its PolicyCallback via this object’s SetOnAvatarPolicy().

Public Static Functions

static double GetConnectElapsedMs()

Returns milliseconds elapsed since the most recent Connect() call. Safe to call from any thread.

3.5.4. Classes

struct ClientServerState

The generic state of the client hardware device e.g. headset, controllers etc. There exists one of these for each server, plus one for the null server (local state).

class ClientPipeline

Contains the full pipeline and member nodes for the client.

Public Functions

void Debug_BreakConnection()

Break the connection without logging off - the server should initiate reconnection.

class Config

Public Functions

void StoreRecentURL(const char *r)

When we connect, store the URL.

void SetStorageFolder(const char *f)

Where do we store temp files?

class DiscoveryService

Abstract discovery service for clients to connect to the server.

Public Functions

uint64_t Discover(uint64_t server_uid, std::string serverIP, uint16_t serverDiscoveryPort)

Returns Client ID.

class OpenXR

Subclassed by teleport::UseOpenXR, teleport::android::OpenXR

Public Functions

void SetFallbackBinding(ActionId actionId, std::string path)

Set a “virtual” pose binding - e.g. mouse emulation.

void OnMouseButtonPressed(bool bLeftButtonDown, bool bRightButtonDown, bool bMiddleButtonDown, int nMouseWheelDelta)

Process mouse and keyboard.

void RemoveNodePoseMapping(avs::uid server_uid, avs::uid uid)

Remove the mapping of the specified node - it has perhaps been unmapped or destroyed.

const std::vector<InputMapping> &GetServerInputMappings(avs::uid server_uid)

Get the currently bound input mappings for the server.

const std::map<avs::uid, NodePoseMapping> &GetServerNodePoseMappings(avs::uid server_uid)

Get the currently bound pose mappings for the server.

const teleport::core::Pose &GetHeadPose_StageSpace() const

Get the head pose in the device’s stage space (axes adapted to the Engineering standard, Z=up).

const std::vector<teleport::core::Pose> &GetTrackedHandJointPoses(int i)

Get the poses relative to the hand root.

teleport::core::Pose GetTrackedHandRootPose(int i) const

Get the hand root pose in local space.

Parameters:

i – index of the hand.

Returns:

struct SignalingServer

Identifies a remote server as seen by the DiscoveryService.