Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Context

Container for an application session. The Context contains all application state for a session of your application. This includes Actors, Users, Assets, and other state.

Hierarchy

  • Context

Implements

Index

Constructors

constructor

Events

offUserJoined

  • offUserJoined(handler: (user: User) => void): this
  • Remove the onUserJoined event handler from the Context.

    Parameters

    • handler: (user: User) => void
        • (user: User): void
        • Parameters

          Returns void

    Returns this

offUserLeft

  • offUserLeft(handler: (user: User) => void): this
  • Remove the onUserLeft event handler from the Context

    Parameters

    • handler: (user: User) => void
        • (user: User): void
        • Parameters

          Returns void

    Returns this

onStarted

  • onStarted(handler: () => void): this
  • The onStarted event is raised after the Context is fully initialized and ready for your application logic to start executing.

    Parameters

    • handler: () => void
        • (): void
        • Returns void

    Returns this

onStopped

  • onStopped(handler: () => void): this
  • The onStopped event is raised before the Context starts shutting down, which happens after the last user disconnects.

    Parameters

    • handler: () => void
        • (): void
        • Returns void

    Returns this

onUserJoined

  • onUserJoined(handler: (user: User) => void): this
  • The onUserJoined event is raised after a new user has joined the Context.

    Parameters

    • handler: (user: User) => void
        • (user: User): void
        • Parameters

          Returns void

    Returns this

onUserLeft

  • onUserLeft(handler: (user: User) => void): this
  • The onUserLeft event is raised when the given user has left the Context. After the last user leaves, the Context will be shutdown (and a 'stopped' event will soon follow).

    Parameters

    • handler: (user: User) => void
        • (user: User): void
        • Parameters

          Returns void

    Returns this

Accessors

actors

animations

conn

rootActors

  • get rootActors(): Actor[]

rpc

  • get rpc(): RPC

rpcChannels

sessionId

  • get sessionId(): string

users

  • get users(): User[]

Methods

actor

animation

asset

getStats

  • getStats(): { actorCount: number; actorWithMeshCount: number; materialCount: number; meshCount: number; meshTrianglesTotal: number; meshVerticesTotal: number; networkBandwidthIn: [number, number, number]; networkBandwidthOut: [number, number, number]; networkMessageCount: [number, number, number]; prefabCount: number; soundCount: number; soundSecondsTotal: number; textureCount: number; texturePixelsAverage: number; texturePixelsTotal: number }
  • Collect and return a snapshot of the current resource usage of the MRE subsystem. For Node process stats, use process.resourceUsage().

    Returns { actorCount: number; actorWithMeshCount: number; materialCount: number; meshCount: number; meshTrianglesTotal: number; meshVerticesTotal: number; networkBandwidthIn: [number, number, number]; networkBandwidthOut: [number, number, number]; networkMessageCount: [number, number, number]; prefabCount: number; soundCount: number; soundSecondsTotal: number; textureCount: number; texturePixelsAverage: number; texturePixelsTotal: number }

    • actorCount: number

      The number of actors in the scene.

    • actorWithMeshCount: number

      The number of visible actors with meshes assigned, not including library actors. For a mobile user with only one MRE running, this should generally be kept below 60, though higher can be done with judicious use of mesh/material reuse and instancing.

    • materialCount: number

      The number of loaded material assets.

    • meshCount: number

      The number of loaded mesh assets.

    • meshTrianglesTotal: number

      The total number of polygons of all loaded meshes.

    • meshVerticesTotal: number

      The total number of vertices of all loaded meshes. Corresponds to GPU memory usage.

    • networkBandwidthIn: [number, number, number]

      The average incoming bandwidth of this app over the last 1/5/30 seconds, in KB/s. This is roughly equivalent to the bandwidth sent by the busiest client over the interval, though does not correlate exactly. Only MRE internal traffic is counted, not general HTTP requests (static file hosting, etc.).

    • networkBandwidthOut: [number, number, number]

      The average outgoing bandwidth of this app over the last 1/5/30 seconds, in KB/s. This is roughly equivalent to the bandwidth sent to the busiest client over the interval, though this does not correlate exactly. Only MRE internal traffic is counted, not general HTTP requests (static file hosting, etc.).

    • networkMessageCount: [number, number, number]

      The number of messages sent and received by this app in the last 1/5/30 seconds. A high number might indicate that clients are wasting CPU cycles serializing and deserializing messages.

    • prefabCount: number

      The number of loaded prefab assets.

    • soundCount: number

      The number of loaded sound assets.

    • soundSecondsTotal: number

      The total number of seconds of loaded audio.

    • textureCount: number

      The number of loaded texture assets.

    • texturePixelsAverage: number

      [[texturePixelsTotal]] divided by [[textureCount]]. If this value exceeds 1024 * 1024 (roughly 1 000 000), clients may experience frame drops during loading.

    • texturePixelsTotal: number

      The total number of pixels of all loaded textures. Corresponds to GPU memory usage. Should be kept below 6 000 000 for mobile device clients.

quit

  • quit(): void

user