MultiplayerSession
ClassAn instance of a Connected Lens session among a group of participants who were successfully invited into the experience.
- Available on all platforms
Since Lens Scripting v148
Index
Properties
Methods
Extends
Properties
activeUserCount
readonlyactiveUserCount:number
Get the number of active users in the Session.
Since
Lens Scripting Version 176
activeUsersInfo
readonlyactiveUsersInfo:UserInfo[]
Since
Lens Scripting Version 148
allRealtimeStores
readonlyallRealtimeStores:GeneralDataStore[]
Get all the Realtime Stores in the current session.
Since
Lens Scripting Version 148
Methods
clearRealtimeStoreOwnership()
clearRealtimeStoreOwnership(
store,onSuccess,onError):void
Sets the realtime store to unowned.
Parameters
| Parameter | Type |
|---|---|
store | GeneralDataStore |
onSuccess | (store) => void |
onError | (message) => void |
Returns
void
Since
Lens Scripting Version 173
createRealtimeStore()
createRealtimeStore(
options,onSuccess,onError):void
Creates a realtime store to share data within a multiplayer session. The realtime store will allow you to pass data between multiple connected users in the same experience, such as: syncing the position of objects in the scene, syncing the current game score, etc.
Parameters
| Parameter | Type |
|---|---|
options | RealtimeStoreCreateOptions |
onSuccess | (store) => void |
onError | (message) => void |
Returns
void
Since
Lens Scripting Version 173
deleteRealtimeStore()
deleteRealtimeStore(
store,onSuccess,onError):void
Deletes a realtime store.
Parameters
| Parameter | Type |
|---|---|
store | GeneralDataStore |
onSuccess | (store) => void |
onError | (message) => void |
Returns
void
Since
Lens Scripting Version 173
getLobbyState()
getLobbyState():
LobbyState
Camera Kit
Returns the confirmed gate of an open-lobby session. It is Unset until the server confirms the gate.
Returns
Since
Lens Scripting Version 387
Example
var lobbyState = session.getLobbyState();
getLocalUserId()
getLocalUserId(
localUserIdCallback):void
Parameters
| Parameter | Type |
|---|---|
localUserIdCallback | (userId) => void |
Returns
void
Since
Lens Scripting Version 148
getLocalUserInfo()
getLocalUserInfo(
localUserInfoCallback):void
Gets information about the current user, which includes their display name and unique userID which can be used to identify them in session.
Parameters
| Parameter | Type |
|---|---|
localUserInfoCallback | (userInfo) => void |
Returns
void
Since
Lens Scripting Version 173
getRealtimeStoreInfo()
getRealtimeStoreInfo(
store):RealtimeStoreCreationInfo
Returns information about the passed in RealtimeStore.
Parameters
| Parameter | Type |
|---|---|
store | GeneralDataStore |
Returns
Since
Lens Scripting Version 181
getSafeSnapchatUser()
getSafeSnapchatUser(
userInfo,safeSnapchatUserCallback):void
Get the SafeUser for a user in the session. This returns only non-sensitive user info (userId, bitmojiInfo, name) suitable for Bitmoji rendering.
Parameters
| Parameter | Type |
|---|---|
userInfo | UserInfo |
safeSnapchatUserCallback | (safeSnapchatUser) => void |
Returns
void
Since
Lens Scripting Version 349
getServerTimestamp()
getServerTimestamp():
number
Returns a unix timestamp in milliseconds of the current time according to the server. Useful for synchronizing time-based game events across devices.
-1 will be returned if session is not connected to the server.
Returns
number
Since
Lens Scripting Version 148
getSnapchatUser()
getSnapchatUser(
userInfo,userCallback):void
SPECS
Get the User for a participant in the session.
Parameters
| Parameter | Type |
|---|---|
userInfo | UserInfo |
userCallback | (user) => void |
Returns
void
Since
Lens Scripting Version 148
getTypeName()
staticgetTypeName():TypeName<MultiplayerSession>
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<MultiplayerSession>
Since
Lens Scripting Version 148
Overrides
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
isOfType()
isOfType(
type):boolean
Returns true if the object matches or derives from the passed in type.
Parameters
| Parameter | Type |
|---|---|
type | string |
Returns
boolean
Inherited from
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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
requestRealtimeStoreOwnership()
requestRealtimeStoreOwnership(
store,onSuccess,onError):void
Requests for ownership of the realtime store.
Parameters
| Parameter | Type |
|---|---|
store | GeneralDataStore |
onSuccess | (store) => void |
onError | (message) => void |
Returns
void
Since
Lens Scripting Version 173
sendMessage()
sendMessage(
message):void
Sends a string message via the realtime backend.
Parameters
| Parameter | Type |
|---|---|
message | string |
Returns
void
Since
Lens Scripting Version 148
sendMessageWithTimeout()
sendMessageWithTimeout(
message,timeoutMs):void
Sends a string message with a timeout in milliseconds. Allows messages to be dropped from the outgoing message queue when they become too old. Useful to ensure the quick delivery of subsequent messages.
Parameters
| Parameter | Type |
|---|---|
message | string |
timeoutMs | number |
Returns
void
Since
Lens Scripting Version 148
setLobbyState()
setLobbyState(
lobbyState):void
Camera Kit
Requests a gate state for an open-lobby session. The session needs host management (ConnectedLensSessionOptions#hostManagementEnabled), and only the current session host can call this; the server ignores requests from other players. The session must be an open lobby; in any other session nothing is sent. Every participant receives the confirmed state through ConnectedLensSessionOptions#onLobbyStateChanged.
Parameters
| Parameter | Type |
|---|---|
lobbyState | LobbyState |
Returns
void
Since
Lens Scripting Version 387
Example
session.setLobbyState(ConnectedLensModule.MatchmakingConfig.LobbyState.Closed);