wired:portal
Portals between spaces and travel across them.
A two-way portal links two portal prims in separate spaces with the same
link-id. Calling open emits a link-intent in the target space, where a
receiving script completes the connection via pair.
Interface portals
Uses document-id, prim-id, error, document, link-id.
link-intent
Unpaired portal link request originating from source-space.
source-space: document-id | |
link: link-id |
link-status
Resolved link status of a portal this frame.
none | No destination set. |
one-way | Destination set with no link-id (one-way). |
pending | Destination space is still loading or resolving. |
unpaired | Destination space loaded, but no portal paired with this link. |
paired | Paired with a matching portal in the destination space. |
intent-subscription
Queues up to 64 pairing intents.
drain
drain: func(max: u32) -> list<link-intent>dropped
dropped: func() -> u64claim
claim: func(intent: link-intent) -> boolClaims intent for this script; returns true for the single winning
subscriber in the space.
open
open: func(document: borrow<document>, prim: prim-id, target-space: document-id) -> result<_, error>Opens the portal on prim toward target-space as a shared session
write, preserving its dimensions. Fails with invalid-argument if prim
has no portal property.
The link-id is derived deterministically from prim and target-space
so every peer produces the same link.
pair
pair: func(document: borrow<document>, prim: prim-id, intent: link-intent) -> result<_, error>Pairs the portal on prim with an incoming intent as a shared write.
close
Clears this peer's session destination on prim, exposing underlying
layers. No-op if this peer did not open it; consumes no rate quota.
link-state
link-state: func(document: borrow<document>, prim: prim-id) -> result<link-status, error>Returns the portal's resolved status this frame. Fails with not-ready if
the portal is not placed yet.
travel
travel: func(target-space: document-id) -> result<_, error>Moves the local user into target-space, loading it if needed.
current-space
current-space: func() -> result<option<document-id>, error>Returns the local user's current space, or none while transitioning.
intents
intents: func() -> result<intent-subscription, error>Subscribes to incoming pairing intents for the calling script's space.
Source
/// Portals between spaces and travel across them.
///
/// A two-way portal links two portal prims in separate spaces with the same
/// `link-id`. Calling `open` emits a `link-intent` in the target space, where a
/// receiving script completes the connection via `pair`.
package wired:portal;
interface portals {
use wired:core/ids.{document-id, prim-id};
use wired:core/error.{error};
use wired:scene/document.{document};
use wired:scene/properties.{link-id};
/// Unpaired portal link request originating from `source-space`.
record link-intent {
source-space: document-id,
link: link-id,
}
/// Opens the portal on `prim` toward `target-space` as a `shared` session
/// write, preserving its dimensions. Fails with `invalid-argument` if `prim`
/// has no portal property.
///
/// The `link-id` is derived deterministically from `prim` and `target-space`
/// so every peer produces the same link.
open: func(document: borrow<document>, prim: prim-id, target-space: document-id) -> result<_, error>;
/// Pairs the portal on `prim` with an incoming `intent` as a `shared` write.
pair: func(document: borrow<document>, prim: prim-id, intent: link-intent) -> result<_, error>;
/// Clears this peer's session destination on `prim`, exposing underlying
/// layers. No-op if this peer did not open it; consumes no rate quota.
close: func(document: borrow<document>, prim: prim-id) -> result<_, error>;
/// Resolved link status of a portal this frame.
enum link-status {
/// No destination set.
none,
/// Destination set with no `link-id` (one-way).
one-way,
/// Destination space is still loading or resolving.
pending,
/// Destination space loaded, but no portal paired with this link.
unpaired,
/// Paired with a matching portal in the destination space.
paired,
}
/// Returns the portal's resolved status this frame. Fails with `not-ready` if
/// the portal is not placed yet.
link-state: func(document: borrow<document>, prim: prim-id) -> result<link-status, error>;
/// Moves the local user into `target-space`, loading it if needed.
travel: func(target-space: document-id) -> result<_, error>;
/// Returns the local user's current space, or `none` while transitioning.
current-space: func() -> result<option<document-id>, error>;
/// Subscribes to incoming pairing intents for the calling script's space.
intents: func() -> result<intent-subscription, error>;
/// Queues up to 64 pairing intents.
resource intent-subscription {
drain: func(max: u32) -> list<link-intent>;
dropped: func() -> u64;
/// Claims `intent` for this script; returns `true` for the single winning
/// subscriber in the space.
claim: func(intent: link-intent) -> bool;
}
}