Jump to content

OpenSimulator Internals/Code Map/HGEntityTransferModule

From Open Simulator Technical Help

OpenSimulator Internals/Code Map/HGEntityTransferModule

[edit]

Overview

[edit]
OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs

Extends EntityTransferModule. Replaces it when HyperGrid is enabled ([Modules] EntityTransferModule = HGEntityTransferModule). Overrides the key virtual methods to handle cross-grid agent transfer, foreign user logout, appearance restriction, and incoming attachment asset fetching.

Also registers as IUserAgentVerificationModule -- verifies HG client tokens on connection.


Configuration

[edit]
[EntityTransfer] section
Key Default Purpose
LevelHGTeleport 0 Minimum user level required to HG teleport (local users only)
RestrictAppearanceAbroad false If true, enforce exported appearance before HG TP
AccountForAppearance (empty) Comma-separated "First Last" account names whose appearance is the allowed export set

GetFinalDestination() Override

[edit]

Called during DoTeleportInternal() to resolve the true destination.

  1. Calls GridService.GetRegionFlags() to check if the destination region has the Hyperlink flag.
  2. If Hyperlink: calls GatekeeperServiceConnector.GetHyperlinkRegion() -- HTTP request to the foreign grid's Gatekeeper service.
    • Gatekeeper returns the actual destination GridRegion on the foreign grid.
  3. If not Hyperlink: returns the region unchanged (same as base class).

This is the step that resolves a local hyperlink stub into a real foreign region descriptor.


NeedsClosing() Override

[edit]

Returns true (source agent should be fully closed after transfer) if:

  • OutViewRange is true, OR
  • The destination region has the Hyperlink flag or is unknown (flags == -1).

HG teleports always close the source agent regardless of view distance.


CreateAgent() Override

[edit]

Called during DoTeleportInternal() to create the agent at the destination.

  1. Calls GridService.GetRegionFlags() to check if destination is a Hyperlink region.
  2. If Hyperlink (HG teleport):
    • Checks if local user has sufficient UserLevel (>= LevelHGTeleport). Refuses if not.
    • Reads HomeURI from agentCircuit.ServiceURLs.
    • Gets or creates a UserAgentServiceConnector for the home grid.
    • Calls UserAgentService.LoginAgentToGrid() -- HTTP POST to home grid's UserAgent service.
      Home grid's UserAgent service calls the foreign Gatekeeper to create the agent there.
    • Sets logout = true -- flags that this agent should be logged out of the source grid after transfer.
    • Fires TriggerTeleportStart on success.
  3. If not Hyperlink: calls base.CreateAgent() -- normal SimulationService.CreateAgent().

AgentHasMovedAway() Override

[edit]

Called after the agent has successfully moved to destination.

  1. Calls base.AgentHasMovedAway() (currently a no-op in base).
  2. If logout == true (HG teleport):
    • Calls PresenceService.LogoutAgent() -- marks agent offline in source grid's presence table.
    • Calls GridUserService.LoggedOut() -- updates source grid's griduser table with last position.

This is the HG-specific grid logout. The agent is now on the foreign grid and is no longer a presence on the source grid.

DB writes (source grid, HG teleport only)
  • presence -- UPDATE: Online=0, session cleared
  • griduser -- UPDATE: LastPosition, Logout timestamp

ValidateGenericConditions() Override

[edit]

Called before teleport proceeds. For HG teleports with RestrictAppearanceAbroad=true:

  1. Checks if destination is a Hyperlink region.
  2. For local grid users going HG:
    • Checks each wearable slot against the exported appearance (ExportedAppearance property).
    • Checks each attachment against the exported attachment list.
    • Returns false (rejects teleport) if any item is not in the allowed set.

ExportedAppearance: lazy-loaded on first access. Loads appearance for each account in AccountForAppearance from AvatarService, resolves attachment ItemIDs to AssetIDs via InventoryService.


OnConnectionClosed() Override

[edit]

Called when viewer disconnects.

For local grid users: calls IUserAgentService.LogoutAgent() -- notifies home UserAgent service.

For foreign (HG) users:

  1. Gets HomeURI from AgentCircuitData.ServiceURLs.
  2. Creates UserAgentServiceConnector for the home grid.
  3. Calls security.LogoutAgent() -- HTTP POST to foreign home grid's UserAgent service.
  4. Calls base.OnConnectionClosed() -- handles abort-in-transit case.

TeleportHome() Override

[edit]

For local grid users: delegates to base.TeleportHome() which uses GridUserService to find home region.

For foreign (HG) users:

  1. Gets HomeURI from AgentCircuitData.ServiceURLs.
  2. Calls UserAgentService.GetHomeRegion() -- HTTP request to foreign home grid.
  3. Constructs a Gatekeeper GridRegion from the HomeURI.
  4. Calls DoTeleport() with ViaHome flag.

HandleIncomingSceneObject() Override

[edit]

Called when an object crosses into this region from another.

For foreign-user attachments arriving via HGLogin (ViaHGLogin flag set):

  1. Adds object to scene immediately.
  2. Queues an async job on m_incomingSceneObjectEngine (JobEngine, 30s timeout).
  3. Job: creates HGUuidGatherer with the foreign AssetServerURI from AgentCircuitData.
    • Gathers all referenced asset UUIDs from the SOG recursively.
    • Fetches each asset from the foreign grid's asset server.
    • 30-second timeout per gather/fetch step -- removes all jobs for that owner on timeout.
  4. After fetch: calls base.HandleIncomingSceneObject().

For non-HGLogin foreign user attachments (already fetched by first local grid region): calls base directly.

For local user attachments: calls base directly.


HandleIncomingAttachments() Override

[edit]

Same pattern as HandleIncomingSceneObject() but for the attachment list transferred in AgentData during crossing/teleport.

For foreign HGLogin users:

  1. Queues async job.
  2. HGUuidGatherer fetches all attachment assets from foreign AssetServerURI.
  3. On completion: calls base.HandleIncomingAttachments().

Includes sp.IsDeleted check in fetch loop -- aborts if avatar departed during the fetch.


VerifyClient()

[edit]

IUserAgentVerificationModule implementation. Called by Scene.CheckClient() for HG arrivals.

  1. Gets HomeURI from AgentCircuitData.
  2. Creates UserAgentServiceConnector.
  3. Calls security.VerifyClient(SessionID, token) -- HTTP POST to foreign home grid.
  4. Returns true/false.

Incoming Attachment Processing

[edit]

m_incomingSceneObjectEngine: JobEngine with 30-second stall timeout. One engine per region. Processes HG attachment asset fetches serially per owner (CommonId = OwnerID).

RemoveIncomingSceneObjectJobs(commonId): drains the queue and reinserts all jobs except those matching the given owner UUID. Used on timeout to cancel stuck fetches.

Stat registered: "HGIncomingAttachmentsWaiting" -- pull stat showing queue depth.


See Also

[edit]