ConnectedLensSessionOptions
ClassSettings for configuring a Connected Lens session.
- Available on all platforms
Index
Properties
- hostManagementEnabled
- matchmakingConfig
- maxNumberOfInvitations
- onConnected
- onDisconnected
- onError
- onHostUpdated
- onLobbyStateChanged
- onMessageReceived
- onRealtimeStoreCreated
- onRealtimeStoreDeleted
- onRealtimeStoreKeyRemoved
- onRealtimeStoreOwnershipUpdated
- onRealtimeStoreUpdated
- onSessionCreated
- onUserJoinedSession
- onUserLeftSession
Methods
Example
// @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);
}```
## Extends
- [`DirectMultiplayerSessionOptions`](./DirectMultiplayerSessionOptions.mdx)
## Properties
<a id="hostmanagementenabled" className="api-member api-member--property"></a>
### 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
```ts
false
Inherited from
DirectMultiplayerSessionOptions.hostManagementEnabled
matchmakingConfig
matchmakingConfig:
MatchmakingConfig
Optional matchmaking configuration. If set, matchmaking will be enabled when creating a session.
Since
Lens Scripting Version 375
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.matchmakingConfig
maxNumberOfInvitations
maxNumberOfInvitations:
number
Defines maximum number of receipients that a user of connected lens can select while sharing a connected lens session via Invitation flow.
Since
Lens Scripting Version 158
Default Value
64
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
connectionInfo | ConnectionInfo |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onConnected
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
disconnectInfo | string |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onDisconnected
onError
onError: (
session,code,description) =>void
Function to be called when an error occurs in the session life cycle.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
code | string |
description | string |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onError
onHostUpdated
onHostUpdated: (
session,removalInfo) =>void
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
removalInfo | HostUpdateInfo |
Returns
void
Since
Lens Scripting Version 184
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onHostUpdated
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
lobbyState | LobbyState |
Returns
void
Since
Lens Scripting Version 387
Example
options.onLobbyStateChanged = function (session, lobbyState) {
print("lobby state: " + lobbyState);
};
Inherited from
DirectMultiplayerSessionOptions.onLobbyStateChanged
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
userId | string |
message | string |
senderInfo | UserInfo |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onMessageReceived
onRealtimeStoreCreated
onRealtimeStoreCreated: (
session,store,ownerInfo,creationInfo) =>void
Callback function that will be executed when a realtime store is created.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
store | GeneralDataStore |
ownerInfo | UserInfo |
creationInfo | RealtimeStoreCreationInfo |
Returns
void
Since
Lens Scripting Version 173
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onRealtimeStoreCreated
onRealtimeStoreDeleted
onRealtimeStoreDeleted: (
session,store,deleteInfo) =>void
Callback function that will be executed when a realtime store is deleted.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
store | GeneralDataStore |
deleteInfo | RealtimeStoreDeleteInfo |
Returns
void
Since
Lens Scripting Version 173
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onRealtimeStoreDeleted
onRealtimeStoreKeyRemoved
onRealtimeStoreKeyRemoved: (
session,removalInfo) =>void
Function to be called when a key is removed from a RealtimeStore.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
removalInfo | RealtimeStoreKeyRemovalInfo |
Returns
void
Since
Lens Scripting Version 181
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onRealtimeStoreKeyRemoved
onRealtimeStoreOwnershipUpdated
onRealtimeStoreOwnershipUpdated: (
session,store,ownerInfo,ownershipUpdateInfo) =>void
Callback function that will be executed when ownership of a realtime store is updated.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
store | GeneralDataStore |
ownerInfo | UserInfo |
ownershipUpdateInfo | RealtimeStoreOwnershipUpdateInfo |
Returns
void
Since
Lens Scripting Version 173
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onRealtimeStoreOwnershipUpdated
onRealtimeStoreUpdated
onRealtimeStoreUpdated: (
session,store,key,updateInfo) =>void
Callback function that will be executed when a realtime store is updated.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
store | GeneralDataStore |
key | string |
updateInfo | RealtimeStoreUpdateInfo |
Returns
void
Since
Lens Scripting Version 173
Default Value
null
Inherited from
DirectMultiplayerSessionOptions.onRealtimeStoreUpdated
onSessionCreated
onSessionCreated: (
session,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.
Parameters
| Parameter | Type |
|---|---|
session | MultiplayerSession |
sessionCreationType | SessionCreationType |
Returns
void
Since
Lens Scripting Version 148
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
userInfo | UserInfo |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onUserJoinedSession
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
| Parameter | Type |
|---|---|
session | MultiplayerSession |
userInfo | UserInfo |
Returns
void
Since
Lens Scripting Version 148
Inherited from
DirectMultiplayerSessionOptions.onUserLeftSession
Methods
create()
staticcreate():ConnectedLensSessionOptions
Create a new ConnectedLensesOptions object.
Returns
ConnectedLensSessionOptions
Since
Lens Scripting Version 148
getTypeName()
staticgetTypeName():TypeName<ConnectedLensSessionOptions>
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<ConnectedLensSessionOptions>
Overrides
DirectMultiplayerSessionOptions.getTypeName
getTypeName()
getTypeName():
string
Returns the name of this object's type.
Returns
string
Inherited from
DirectMultiplayerSessionOptions.getTypeName
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
DirectMultiplayerSessionOptions.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
| Parameter | Type |
|---|---|
other | ScriptObject |
Returns
boolean
Inherited from
DirectMultiplayerSessionOptions.isSame
Nested types
Enumerations
| Enumeration | Description |
|---|---|
| SessionCreationType | Type of the created Connected Lens session. |