Preparing search index...

    Class ConnectedLensModule

    Enables the creation and management of networked Lens experiences, allowing for real-time communication and interaction between users through Connected Lenses.

    Allows use of networked Lens communication capabilities such as real-time communication, co-located session creation and joining, and shared persistent storage. It's recommended to only use one ConnectedLensModule per Lens.

    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);
    }

    Hierarchy (View Summary)

    Index

    Properties

    name: string

    The name of the Asset in Lens Studio.

    ""
    
    uniqueIdentifier: string

    Lens Scripting Version 176

    Methods

    • Create session with the provided options. Will also check if there is a session that can be created from a session sharetype received from other users.

      Parameters

      Returns void

      Lens Scripting Version 146

    • Asks the host application which multiplayer capabilities are available for this Lens launch, before any session exists. The answer is fetched once and reused for the lifetime of this ConnectedLensModule.

      Currently it reports matchmaking availability, so call this before ConnectedLensModule#createSession to decide whether to set ConnectedLensSessionOptions#matchmakingConfig — attaching a config the host cannot honour fails session creation with a MatchmakingRejectedByClient error instead. Treat any ConnectedLensModule.MatchmakingAvailability other than Supported as "create a direct session".

      Parameters

      Returns void

      Lens Scripting Version 375

      // @input Asset.ConnectedLensModule connectedLensModule

      script.connectedLensModule.getMultiplayerSupportInfo(function (multiplayerSupportInfo) {
      var options = ConnectedLensSessionOptions.create();
      if (multiplayerSupportInfo.matchmakingAvailability ===
      ConnectedLensModule.MatchmakingAvailability.Supported) {
      options.matchmakingConfig = ConnectedLensModule.MatchmakingConfig.create(1, 4);
      }
      options.onSessionCreated = onSessionCreated;
      options.onError = onError;
      script.connectedLensModule.createSession(options);
      });
    • 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 string

    • Returns the name of this object's type.

      Returns string

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

      Parameters

      • type: string

      Returns boolean

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

      Parameters

      Returns boolean

    • Leaves the active Connected Lenses session for the local user. The session's onDisconnected callback fires once for the local user. Other participants will remain in the session. After leaving, the MultiplayerSession object can no longer be used — create a new one with ConnectedLensModule#createSession, for example to start a fresh session when you are the last remaining participant.

      Parameters

      Returns void

      Lens Scripting Version 370

      script.connectedLensModule.leaveSession(session);
      
    • Share the session with other users, specified by the SessionShareType. Note that if shared via Invitation, a new session will be created. Expect a new onConnected callback with the new session being passed in.

      Parameters

      Returns void

      Lens Scripting Version 146