RunicConnection record

Namespace Runic.Application.Views in Runic.Application.Views 0.23.0

public sealed record RunicConnection : IEquatable<RunicConnection>

Inherits or implements IEquatable.

One page connection of a Window: a browser tab, a WebView or a reloaded page, from its hello until it closes.

Parameters

ConnectionKey

The connection's key, unique among the Window's connections.

ClientKey

The browser client's key. Several connections can share one, as a page's reconnects do.

Remarks

Both keys come from the window's transport, which authenticated the connection, never from the page's requests, so a page cannot claim another page's keys. They are opaque: compare them, keep them as dictionary keys, but do not parse them or show them to users. A reload is a new connection with a new RunicConnection.ConnectionKey. On CS-WebUI the RunicConnection.ClientKey is WebUI's client id; on Runic Desktop it identifies the window's page.

Constructors

RunicConnection

public RunicConnection(string ConnectionKey, string ClientKey)

One page connection of a Window: a browser tab, a WebView or a reloaded page, from its hello until it closes.

Parameters

ConnectionKey

The connection's key, unique among the Window's connections.

ClientKey

The browser client's key. Several connections can share one, as a page's reconnects do.

Remarks

Both keys come from the window's transport, which authenticated the connection, never from the page's requests, so a page cannot claim another page's keys. They are opaque: compare them, keep them as dictionary keys, but do not parse them or show them to users. A reload is a new connection with a new RunicConnection.ConnectionKey. On CS-WebUI the RunicConnection.ClientKey is WebUI's client id; on Runic Desktop it identifies the window's page.

Properties

ClientKey

public string ClientKey { get; init; }

The browser client's key. Several connections can share one, as a page's reconnects do.

ConnectionKey

public string ConnectionKey { get; init; }

The connection's key, unique among the Window's connections.

Languages

public IReadOnlyList<string> Languages { get; init; }

The languages the page's browser prefers, most preferred first, as BCP 47 tags such as de-CH: its navigator.languages, which the page reports in its hello (feature client-languages/1, a page of 0.17 or later). Empty when the page reports none.

Exceptions

ArgumentNullException

The value set is null.

Remarks

The tags are in BCP 47 case (de-CH, zh-Hant-TW), each once, whatever case the browser sent. The page reports them; the transport does not check them, so treat them as a preference, never as an identity. A Window shows one language for all of its connections (IRunicWindowLocale): use the languages to choose it, for example from the first connection of a CS-WebUI window, not to translate per connection.

Negotiate them against the locales the application ships, for example with the generated catalog's ResolveLocale, and set the result; never assign a browser's tag to IRunicWindowLocale.Locale directly, or one remote browser chooses an arbitrary language for everyone who shares the window.

The list is personal data that can help fingerprint a browser, and may say more than its Accept-Language header: use it to choose the window's language only, and do not log or store it. A page can stop sending it (configureClientLanguages({ send: false }) of @runic-artifex/views). The list is read-only and copied when it is set.

Methods

Equals

public bool Equals(RunicConnection? other)

Whether other is the same connection: both keys are equal.

Parameters

other

The connection to compare.

Returns

true when both keys are equal.

GetHashCode

public override int GetHashCode()

Inherits documentation from Object.GetHashCode.