Lens Scripting API

    Class MultiplayerSession

    An instance of a Connected Lens session among a group of participants who were successfully invited into the experience.

    Hierarchy (View Summary, Expand)

    Index

    Constructors

    Properties

    activeUserCount: number

    Get the number of active users in the Session.

    activeUsersInfo: UserInfo[]
    allRealtimeStores: GeneralDataStore[]

    Get all the Realtime Stores in the current session.

    Methods

    • Sets the realtime store to unowned.

      Parameters

      Returns 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

      Returns void

    • Deletes the value from the specified scope.

      Parameters

      • key: string
      • scope: StorageScope
      • onDeleted: () => void
      • onError: (code: string, description: string) => void

      Returns void

    • Parameters

      • localUserIdCallback: (userId: string) => void

      Returns 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

      • localUserInfoCallback: (userInfo: UserInfo) => void

      Returns void

    • 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

    • Get a value stored within the specified scope.

      Parameters

      • key: string
      • scope: StorageScope
      • onRetrieved: (
            key: string,
            value:
                | string
                | number
                | boolean
                | vec4
                | vec3
                | quat
                | mat4
                | vec2
                | mat3
                | mat2,
        ) => void
      • onError: (code: string, description: string) => void

      Returns void

    • 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

    • List all values stored within the specified scope.

      Parameters

      • scope: StorageScope
      • cursor: string
      • onRetrieved: (
            values: (
                | string
                | number
                | boolean
                | vec4
                | vec3
                | quat
                | mat4
                | vec2
                | mat3
                | mat2
            )[][],
            cursor: string,
        ) => void
      • onError: (code: string, description: string) => void

      Returns void

    • Requests for ownership of the realtime store.

      Parameters

      Returns void

    • Sends a string message via the realtime backend.

      Parameters

      • message: string

      Returns 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

      • message: string
      • timeoutMs: number

      Returns void

    • Saves the value to the specified scope.

      Parameters

      Returns void

    MMNEPVFCICPMFPCPTTAAATR