Settings for configuring a Connected Lens session.

// @input Asset.ConnectedLensModule connectedLensModule
function createSession() {
var options = ConnectedLensSessionOptions.create();

options.onSessionCreated = onSessionCreated;
options.onConnected = onConnected;
options.onDisconnected = onDisconnected;
options.onMessageReceived = onMessageReceived;
options.onUserJoinedSession = onUserJoinedSession;
options.onUserLeftSession = onUserLeftSession;
options.onError = onError;

script.connectedLensModule.createSession(options);
}
interface ConnectedLensSessionOptions {
    hostManagementEnabled: boolean;
    maxNumberOfInvitations: number;
    onConnected: ((session: MultiplayerSession, connectionInfo: ConnectionInfo) => void);
    onDisconnected: ((session: MultiplayerSession, disconnectInfo: string) => void);
    onError: ((session: MultiplayerSession, code: string, description: string) => void);
    onHostUpdated: ((session: MultiplayerSession, removalInfo: HostUpdateInfo) => void);
    onMessageReceived: ((session: MultiplayerSession, userId: string, message: string, senderInfo: UserInfo) => void);
    onRealtimeStoreCreated: ((session: MultiplayerSession, store: GeneralDataStore, ownerInfo: UserInfo, creationInfo: RealtimeStoreCreationInfo) => void);
    onRealtimeStoreDeleted: ((session: MultiplayerSession, store: GeneralDataStore, deleteInfo: RealtimeStoreDeleteInfo) => void);
    onRealtimeStoreKeyRemoved: ((session: MultiplayerSession, removalInfo: RealtimeStoreKeyRemovalInfo) => void);
    onRealtimeStoreOwnershipUpdated: ((session: MultiplayerSession, store: GeneralDataStore, ownerInfo: UserInfo, ownershipUpdateInfo: RealtimeStoreOwnershipUpdateInfo) => void);
    onRealtimeStoreUpdated: ((session: MultiplayerSession, store: GeneralDataStore, key: string, updateInfo: RealtimeStoreUpdateInfo) => void);
    onSessionCreated: ((session: MultiplayerSession, sessionCreationType: SessionCreationType) => void);
    onUserJoinedSession: ((session: MultiplayerSession, userInfo: UserInfo) => void);
    onUserLeftSession: ((session: MultiplayerSession, userInfo: UserInfo) => void);
    getTypeName(): string;
    isOfType(type: string): boolean;
    isSame(other: ScriptObject): boolean;
}

Hierarchy (view full)

Properties

hostManagementEnabled: boolean

Provides a single host for every session. Useful when an experience has a single authority. This should not be used in latency sensitive situations. The creator of the session will by default be the host. If the host leaves, thee server will determine a new host and transfer all ownership of entities owned by the original host. Use with onHostUpdated API to get a callback.

maxNumberOfInvitations: number

Defines maximum number of receipients that a user of connected lens can select while sharing a connected lens session via Invitation flow.

onConnected: ((session: MultiplayerSession, connectionInfo: ConnectionInfo) => void)

Function to be called when a connection to the realtime backend is established. All realtime requests can be called after this callback. When you invite others to join, a new session will be created, hence you should update your session handler with the argument passed in this callback.

onDisconnected: ((session: MultiplayerSession, disconnectInfo: string) => void)

Function to be called when the connection to the realtime backend is lost, either via successful disconnect or passive disconnect due to error.

onError: ((session: MultiplayerSession, code: string, description: string) => void)

Function to be called when an error occurs in the session life cycle.

onHostUpdated: ((session: MultiplayerSession, removalInfo: HostUpdateInfo) => void)
onMessageReceived: ((session: MultiplayerSession, userId: string, message: string, senderInfo: UserInfo) => void)

Function to be called when a string-based message sent by sendMessage() is received from another user via the realtime backend.

onRealtimeStoreCreated: ((session: MultiplayerSession, store: GeneralDataStore, ownerInfo: UserInfo, creationInfo: RealtimeStoreCreationInfo) => void)

Callback function that will be executed when a realtime store is created.

onRealtimeStoreDeleted: ((session: MultiplayerSession, store: GeneralDataStore, deleteInfo: RealtimeStoreDeleteInfo) => void)

Callback function that will be executed when a realtime store is deleted.

onRealtimeStoreKeyRemoved: ((session: MultiplayerSession, removalInfo: RealtimeStoreKeyRemovalInfo) => void)

Function to be called when a key is removed from a RealtimeStore.

onRealtimeStoreOwnershipUpdated: ((session: MultiplayerSession, store: GeneralDataStore, ownerInfo: UserInfo, ownershipUpdateInfo: RealtimeStoreOwnershipUpdateInfo) => void)

Callback function that will be executed when ownership of a realtime store is updated.

onRealtimeStoreUpdated: ((session: MultiplayerSession, store: GeneralDataStore, key: string, updateInfo: RealtimeStoreUpdateInfo) => void)

Callback function that will be executed when a realtime store is updated.

onSessionCreated: ((session: MultiplayerSession, sessionCreationType: SessionCreationType) => void)

Function called when the session is created. The session creation type in this callback can be used to tell if the session is being created from scratch, or is being received from another user.

onUserJoinedSession: ((session: MultiplayerSession, userInfo: UserInfo) => void)

Function to be called when another user joins the session. When joining a session, the current user will get a callback for each of the existing active users in the current session. This way you can build a list of existing players in game.

onUserLeftSession: ((session: MultiplayerSession, userInfo: UserInfo) => void)

Function to be called when another user leaves the session, either deliberately or via passive disconnect due to error.

Methods