WorldNetworkGate
La référence est en anglais : elle est générée à partir des commentaires du code, écrits en anglais.
public sealed class WorldNetworkGate : IFluxNetworkGateNamespace NodeWorld.SDK.Client.Flux.
The one door between a world and the Internet on the client: web (HttpClient), WebSocket, images and video of the FL# scripts go through it, never the client's own requests (API, avatars). A choice is kept per hostname (Ruby: « par hostname »), for every world, on this device: the domain with its subdomains (the Public Suffix List tells where the domain starts: allowing helicityohno.github.io does not allow github.io), or an IP address. The big video sites are allowed from the start, a list the player edits (« Liste déjà faite modifiable »). A request waits for the player's answer or for the world to leave. An IP of this machine or of the local network written by the world asks with a warning; a name that points there is refused. In the Unity editor everything is allowed (« Tout autorisé dans l'éditeur »). Logs: "[Web]" with the hostname only.
Fields
ShippedVideoSites
public static readonly IReadOnlyList<string> ShippedVideoSitesThe video sites the client ships (Ruby: « Grands sites vidéo »).
Constructors
WorldNetworkGate
public WorldNetworkGate(string path, bool allowEverything)A gate kept in that file (tests); allowEverything: the editor's rule.
Properties
Shared
public static WorldNetworkGate Shared { get; }The gate of this device (created on the main thread the first time; kept in persistentDataPath).
AllowEverything
public bool AllowEverything { get; set; }Everything allowed without a window (the Unity editor).
WorldId
public string WorldId { get; }The world now (set by the FL# runtime when a world starts), null between worlds.
Resolve
public Func<string, CancellationToken, Task<IPAddress[]>> Resolve { get; set; }The name resolver (tests replace it).
Allowed
public IReadOnlyList<string> Allowed { get; }Hostnames allowed for good.
Refused
public IReadOnlyList<string> Refused { get; }Hostnames refused for good.
VideoSites
public IReadOnlyList<string> VideoSites { get; }The video sites allowed without a window (the shipped list, as the player edited it).
Pending
public IReadOnlyList<WorldNetworkRequest> Pending { get; }Requests waiting for the player.
Methods
BeginWorld
public void BeginWorld(string worldId)A world starts: its requests will name it.
EndWorld
public void EndWorld()The world leaves: "This time" ends, the requests still waiting are dropped (their windows go).
AuthorizeAsync
public async Task<IPAddress[]> AuthorizeAsync(FluxWebAddress address, CancellationToken cancellationToken)A web request or WebSocket of the world: waits for the player's choice for its domain (or IP address), then gives the addresses to connect to. Throws FluxNetworkRefusedException when the player refused it, or when its name points to this machine or the local network.
AuthorizeVideoAsync
public async Task<bool> AuthorizeVideoAsync(string url, CancellationToken cancellationToken)A video address (any network protocol libVLC reads: http, https, rtmp, rtsp, udp, mms, srt...): true when the world may open it. libVLC and yt-dlp resolve the name themselves, the gate checks it first (a name that points to the local network is refused). The media servers yt-dlp finds next are the resolver's, not the world's: not asked.
IsVideoScheme
public static bool IsVideoScheme(string scheme)The network protocols of libVLC a world may use for a video (no local file, screen or capture device).
KeyOf
public static string KeyOf(FluxWebAddress address)What a choice is kept for: the domain of a name (with its subdomains) or the IP address, with the port when it is not the standard one.
Covers
public static bool Covers(string kept, string hostname)A kept hostname covers this hostname (host with its port when not standard): the same, or a subdomain of it on the same port. A kept public suffix (github.io itself) covers only itself, an IP address only itself.
Forget
public void Forget(string hostname)Removes a hostname from the allowed or refused ones: the next request to it asks again.
AddVideoSite
public bool AddVideoSite(string text)Adds a video site (a hostname the player types): allowed without a window from now on. False if it is not a hostname.
RemoveVideoSite
public void RemoveVideoSite(string site)Removes a video site: a world asks for it again.
NormalizeTyped
public static string NormalizeTyped(string text)A hostname as the player types it (https://www.Example.com/x, example.com:8080): its normalized form, null if it is none.
Events
Asked
public event Action<WorldNetworkRequest> AskedA world asks a hostname the player has not answered (on the main thread): the window and the notification show it.
Settled
public event Action<WorldNetworkRequest> SettledA request was answered or dropped (on the main thread): its window and notification go.
Changed
public event Action ChangedThe lists changed (on the main thread): the settings repaint.
Removed
public event Action RemovedThe player removed a choice or a video site in the settings (on the main thread).
