TeleportDataService
Server half of the symmetric teleport-data surface. Two responsibilities:
- Building teleport data through a shared TeleportDataBuilder, so every teleport site assembles the same envelope from the same providers (see TeleportDataService.PromiseBuildTeleportData).
- Reading the data a player arrived with, as a unified view across two trust bands.
The trust split is the load-bearing idea. A player's arrived data reaches the server two ways:
-
the trusted band --
player:GetJoinData().TeleportData-- which Roblox only populates for a server-initiated teleport, so it is genuinely server-authored and safe to authorize on; and -
the non-trusted band -- what the client read from its own local teleport data
(
GetLocalPlayerTeleportData) and replicated back to us. A client-initiated teleport (e.g. a menu teleporting the local player) only ever reaches the server this way, so without it the server is blind to data the client can see.
The unified read (TeleportDataService.PromiseArrivedData) merges both with the trusted band winning, so a client can never override a key the server set. Because the non-trusted band arrives over the network, every read is a [Promise]: it resolves once the client has replicated (or a bounded timeout falls back to the trusted band alone, so a stale client can never hang a read forever). A PlayerMock has no client to wait for, so its reads fall back at the next resumption step instead of the production window -- a spec injects arrived data (via the testing seams) before yielding. Code that must not trust the client reads the trusted band explicitly via TeleportDataService.PromiseTrustedArrivedData; the unified accessor is deliberately un-named for trust so trusting client data is always a visible choice.
Functions
RegisterTeleportDataProvider
Registers a shared provider (contributes to every player's teleport data). See TeleportDataBuilder.RegisterTeleportDataProvider. Returns an unregister function.
RegisterPerPlayerTeleportDataProvider
TeleportDataService.RegisterPerPlayerTeleportDataProvider(provider: PerPlayerTeleportDataProvider) → () → ()Registers a per-player provider. See TeleportDataBuilder.RegisterPerPlayerTeleportDataProvider. Returns an unregister function.
PromiseBuildTeleportData
Builds the teleport data envelope, awaiting any provider that returns a Promise. See TeleportDataBuilder.PromiseBuildTeleportData. Use this when a provider assembles its slice asynchronously (e.g. persisting live state before a teleport).
_getUserId
Resolves the UserId used to key a player's envelope slice. A method so tests can stand in a fake player (which has no UserId) by overriding it.
PromiseArrivedData
Returns the unified teleport data the player arrived with -- the trusted band (server join data) merged over the non-trusted band (client-replicated), trusted winning -- or nil. Resolves once the client has replicated its band, or when the bounded timeout falls back to the trusted band alone.
This is the everyday accessor. It may contain client-authored keys, so treat it as a request, not an authority; for authoritative reads use TeleportDataService.PromiseTrustedArrivedData.
PromiseTrustedArrivedData
Returns the trusted-band teleport data the player arrived with (server-authored, from join data), or nil. Safe to authorize on -- a client can never place data here. Resolves once the arrival is sealed.
PromiseNonTrustedArrivedData
Returns the non-trusted-band teleport data the player arrived with (client-replicated), or nil. Rarely needed directly; prefer the unified TeleportDataService.PromiseArrivedData.
PromiseArrivedValue
Returns the unified value the player arrived with under key, or nil.
PromiseHasArrivedValue
Returns whether the player arrived with a unified value under key.
PromiseTrustedArrivedValue
Returns the trusted-band value the player arrived with under key, or nil. Safe to authorize on.
PromiseHasTrustedArrivedValue
Returns whether the player arrived with a trusted-band value under key.
PromiseArrivedValueIsTrusted
Returns whether the unified value for key came from the trusted band -- i.e. whether it is safe to
authorize on. Defense-in-depth for code that reads the unified view but must occasionally assert
provenance without a second read.
SetTrustedArrivedTeleportDataForTesting
TeleportDataService.SetTrustedArrivedTeleportDataForTesting() → ()Overrides the trusted arrived band for a player. Test seam -- headless servers have no join data, so specs inject what a player would have arrived with from a server teleport. Must be set before any read seals the arrival.
SetNonTrustedArrivedTeleportDataForTesting
TeleportDataService.SetNonTrustedArrivedTeleportDataForTesting() → ()Simulates the client's non-trusted band arriving (the replication the real client pushes). Test seam. First arrival wins and seals; later calls are ignored, mirroring production first-wins semantics.
SetReplicationTimeoutForTesting
Sets the bounded wait before a read falls back to the trusted band alone. Test seam, so a spec can drive the timeout path deterministically without waiting the production window.