RTSDK
    Preparing search index...

    Class WorldActivity

    Create an instance of WorldActivity class with a given url slug and optional attributes and session credentials.

    This class is responsible for all activity of a specified world including editing dropped assets, moving current visitors, etc.

    import { WorldActivity } from "utils/topiaInit.ts";

    const activity = await WorldActivity.create(urlSlug, {
    attributes: { name: "Example World" },
    credentials: { interactivePublicKey: "examplePublicKey", interactiveNonce: "exampleNonce", assetId: "exampleDroppedAssetId", visitorId: 1, urlSlug: "exampleUrlSlug" }
    });

    Hierarchy (View Summary)

    Index

    Other

    credentials: undefined | InteractiveCredentials
    jwt?: string
    requestOptions: object
    topia: Topia
    urlSlug: string
    • get visitors(): { [key: string]: Visitor }

      Returns { [key: string]: Visitor }

    • Standardized error handler for all SDK operations.

      Parameters

      • __namedParameters: { error?: unknown; message?: string; params?: object; sdkMethod?: string }

      Returns {
          data: {};
          message: string;
          method: string;
          params: object;
          sdkMethod: undefined | string;
          stack: string;
          stackTrace: Error;
          status: number;
          success: boolean;
          url: string;
      }

      Standardized error object with properties: data, message, method, params, sdkMethod, stack, status, success, url

      This method processes errors from API calls and formats them consistently across the SDK. It extracts relevant error information including:

      • HTTP status codes and response data
      • Error messages from API responses
      • Stack traces for debugging
      • Request details (URL, method, parameters)

      All errors thrown by SDK methods flow through this handler to ensure consistent error format.

      error, exception, handler, debugging, api error, http error

    • Returns the configured Axios instance for making API calls to Topia's Public API.

      Returns AxiosInstance

      The configured Axios client instance with authentication headers.

      All HTTP requests to the Topia API should use this method to ensure proper authentication headers and base URL configuration are applied.

      api, axios, http, request, client, public api

    Visitors

    • Retrieve all visitors currently in a world.

      Parameters

      • OptionalshouldIncludeAdminPermissions: boolean

      Returns Promise<{ [key: string]: Visitor }>

      Returns the an object containing current visitors keyed by visitorId or an error.

      get, fetch, retrieve, list, current, visitors, users, players

      const visitors = await worldActivity.currentVisitors("exampleLandmarkZoneId", true);
      
    • Retrieve all visitors currently in a Landmark Zone.

      Parameters

      • __namedParameters: { droppedAssetId?: string; shouldIncludeAdminPermissions?: boolean }

      Returns Promise<{ [key: string]: Visitor }>

      Returns the an object containing current visitors keyed by visitorId or an error.

      get, fetch, retrieve, list, zone, area, landmark, visitors, users

      const visitors = await worldActivity.fetchVisitorsInZone({ droppedAssetId: "exampleDroppedAssetId" });
      
    • Move all visitors currently in a world to a single set of coordinates.

      Parameters

      Returns Promise<undefined | (void | ResponseType)[]>

      Updates each Visitor instance and worldActivity.visitors map.

      Optionally refetch visitors, teleport or walk visitors to new location, and scatter visitors by any number so that they don't all move to the exact same location.

      move, teleport, position, coordinate, visitors, users, relocate

      await worldActivity.moveAllVisitors({
      shouldFetchVisitors: true,
      shouldTeleportVisitors: true,
      scatterVisitorsBy: 40,
      x: 100,
      y: 100,
      });
    • Teleport or walk a list of visitors currently in a world to various coordinates.

      Parameters

      Returns Promise<(void | ResponseType)[]>

      Updates each Visitor instance and worldActivity.visitors map.

      move, teleport, position, coordinate, visitor, user, relocate

      const visitorsToMove = [
      {
      visitorObj: worldActivity.visitors["1"],
      shouldTeleportVisitor: true,
      x: 100,
      y: 100
      }, {
      visitorObj: worldActivity.visitors["2"],
      shouldTeleportVisitor: false,
      x: 100,
      y: 100
      }
      ];
      await worldActivity.moveVisitors(visitorsToMove);