Skip to main content

BaseMultiplayerSessionOptions

Class

Base class for MultiplayerSession options.

  • Available on all platforms
Platform details: Snapchat, SPECS, Camera Kit Web, Camera Kit Mobile fully supported.

Platform details

  • Snapchat — Fully supported.

  • SPECS — Fully supported.

  • Camera Kit Web — Fully supported.

  • Camera Kit Mobile — Fully supported.

Base class for MultiplayerSession options. This class is not used directly - use ConnectedLensSessionOptions instead.

Index

Extends

Extended by

Properties

hostManagementEnabled

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.

Default Value

false

matchmakingConfig

matchmakingConfig: MatchmakingConfig

Optional matchmaking configuration. If set, matchmaking will be enabled when creating a session.

Since

Lens Scripting Version 375

Default Value

null

onConnected

onConnected: (session, 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.

Parameters

ParameterType
sessionMultiplayerSession
connectionInfoConnectionInfo

Returns

void

Since

Lens Scripting Version 148


onDisconnected

onDisconnected: (session, disconnectInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
disconnectInfostring

Returns

void

Since

Lens Scripting Version 148


onError

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

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

Parameters

ParameterType
sessionMultiplayerSession
codestring
descriptionstring

Returns

void

Since

Lens Scripting Version 148


onHostUpdated

onHostUpdated: (session, removalInfo) => void

Parameters

ParameterType
sessionMultiplayerSession
removalInfoHostUpdateInfo

Returns

void

Since

Lens Scripting Version 184

Default Value

null

onLobbyStateChanged

onLobbyStateChanged: (session, lobbyState) => void

Camera Kit

Function called on every participant when the server confirms the gate of an open-lobby session. The first confirmation can repeat the current state. A player who joins after the confirmation gets no call; read MultiplayerSession#getLobbyState in onConnected instead. Handling this is optional.

Parameters

ParameterType
sessionMultiplayerSession
lobbyStateLobbyState

Returns

void

Since

Lens Scripting Version 387

Example

options.onLobbyStateChanged = function (session, lobbyState) {
print("lobby state: " + lobbyState);
};

onMessageReceived

onMessageReceived: (session, userId, message, senderInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
userIdstring
messagestring
senderInfoUserInfo

Returns

void

Since

Lens Scripting Version 148


onRealtimeStoreCreated

onRealtimeStoreCreated: (session, store, ownerInfo, creationInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
storeGeneralDataStore
ownerInfoUserInfo
creationInfoRealtimeStoreCreationInfo

Returns

void

Since

Lens Scripting Version 173

Default Value

null

onRealtimeStoreDeleted

onRealtimeStoreDeleted: (session, store, deleteInfo) => void

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

Parameters

Returns

void

Since

Lens Scripting Version 173

Default Value

null

onRealtimeStoreKeyRemoved

onRealtimeStoreKeyRemoved: (session, removalInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
removalInfoRealtimeStoreKeyRemovalInfo

Returns

void

Since

Lens Scripting Version 181

Default Value

null

onRealtimeStoreOwnershipUpdated

onRealtimeStoreOwnershipUpdated: (session, store, ownerInfo, ownershipUpdateInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
storeGeneralDataStore
ownerInfoUserInfo
ownershipUpdateInfoRealtimeStoreOwnershipUpdateInfo

Returns

void

Since

Lens Scripting Version 173

Default Value

null

onRealtimeStoreUpdated

onRealtimeStoreUpdated: (session, store, key, updateInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
storeGeneralDataStore
keystring
updateInfoRealtimeStoreUpdateInfo

Returns

void

Since

Lens Scripting Version 173

Default Value

null

onUserJoinedSession

onUserJoinedSession: (session, 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.

Parameters

ParameterType
sessionMultiplayerSession
userInfoUserInfo

Returns

void

Since

Lens Scripting Version 148


onUserLeftSession

onUserLeftSession: (session, userInfo) => void

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

Parameters

ParameterType
sessionMultiplayerSession
userInfoUserInfo

Returns

void

Since

Lens Scripting Version 148

Methods

getTypeName()

static getTypeName(): TypeName<BaseMultiplayerSessionOptions>

Returns the fully-qualified JavaScript type name for this class (for example, "Component.Camera"). This is a static accessor (no instance required) and returns the same value as the instance getTypeName().

Returns

TypeName<BaseMultiplayerSessionOptions>

Overrides

ScriptObject.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

ScriptObject.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object matches or derives from the passed in type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

ScriptObject.isOfType


isSame()

isSame(other): boolean

Returns true if this object is the same as other. Useful for checking if two references point to the same thing.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

ScriptObject.isSame