Skip to main content
Version: Dev (main)

PanelContentControl class

Serves web pages to GUI panels from this session and exchanges JSON messages with them. Reached through Session.PanelContent.

Namespace: Quaternar.Qaros · Assembly: Quaternar.Qaros.dll

public sealed class PanelContentControl

Remarks​

A served GUI panel shows a page of a content bundle: a named, versioned set of files this session publishes once. Every user's mixer loads the page in its own browser, fetching the files over the session, so each user has their own page state. The page sends with qaros.panel.send(msg) and receives with qaros.panel.onMessage(cb).

Publishing copies every byte: nothing on disk is read while serving, and an edit needs another publication, which reloads every panel showing the bundle. Only the publisher may put its bundle on a panel, receives the panels' messages and posts to them. Limits: 16 MiB per file, 64 MiB and 1024 files per bundle, 64 KiB per message.

Methods​

MemberDescription
PublishDirectory(string, string)Publishes every regular file under root as bundle name, replacing an earlier publication of that name. A link inside the folder is refused, as is every file PanelContentControl.PublishFiles refuses.
PublishFiles(string, IReadOnlyList<PanelContentFile>)Publishes files as bundle name, replacing an earlier publication of that name. Nothing is published when it fails: a bad name (StatusCode.PanelContentBundleRefused), a bad or duplicate path (StatusCode.PanelContentPathRefused), a type that is not served (StatusCode.PanelContentMimeRefused) or a limit exceeded (StatusCode.PanelContentSizeRefused).
Remove(PanelContentBundleId)Stops serving a bundle this session published. Panels showing it stay and show nothing.
SubscribeMessages(PanelContentBundleId, EventHandler<PanelContentMessageEventArgs>, CancellationToken)Receives the messages of every panel showing a bundle this session published, each stamped with its panel and user. Disposing the result, cancelling the token, removing the bundle or closing the session stops delivery.
PostMessage(PanelContentBundleId, string, GuiPanelId?, PeerId?)Posts one JSON value to the panels showing a bundle this session published: to one panel or all (panel null), for one user or all (user null).

PublishDirectory​

Publishes every regular file under root as bundle name, replacing an earlier publication of that name. A link inside the folder is refused, as is every file PanelContentControl.PublishFiles refuses.

public Result<PanelContentBundleId> PublishDirectory(string name, string root)

Parameters

NameTypeDescription
namestring
rootstring

Returns: Result<PanelContentBundleId>

PublishFiles​

Publishes files as bundle name, replacing an earlier publication of that name. Nothing is published when it fails: a bad name (StatusCode.PanelContentBundleRefused), a bad or duplicate path (StatusCode.PanelContentPathRefused), a type that is not served (StatusCode.PanelContentMimeRefused) or a limit exceeded (StatusCode.PanelContentSizeRefused).

public Result<PanelContentBundleId> PublishFiles(string name, IReadOnlyList<PanelContentFile> files)

Parameters

NameTypeDescription
namestring
filesIReadOnlyList<PanelContentFile>

Returns: Result<PanelContentBundleId>

Remove​

Stops serving a bundle this session published. Panels showing it stay and show nothing.

public Result<Unit> Remove(PanelContentBundleId bundle)

Parameters

NameTypeDescription
bundlePanelContentBundleId

Returns: Result<Unit>

SubscribeMessages​

Receives the messages of every panel showing a bundle this session published, each stamped with its panel and user. Disposing the result, cancelling the token, removing the bundle or closing the session stops delivery.

public Result<IDisposable> SubscribeMessages(PanelContentBundleId bundle, EventHandler<PanelContentMessageEventArgs> handler, CancellationToken cancellationToken = default)

Parameters

NameTypeDescription
bundlePanelContentBundleId
handlerEventHandler<PanelContentMessageEventArgs>
cancellationTokenCancellationToken

Returns: Result<IDisposable>

Remarks

The handler runs on a library thread and an exception it throws is dropped. Validate each message before acting on it, and authorise per PanelContentMessage.User.

PostMessage​

Posts one JSON value to the panels showing a bundle this session published: to one panel or all (panel null), for one user or all (user null).

public Result<Unit> PostMessage(PanelContentBundleId bundle, string json, GuiPanelId? panel = null, PeerId? user = null)

Parameters

NameTypeDescription
bundlePanelContentBundleId
jsonstring
panelGuiPanelId?
userPeerId?

Returns: Result<Unit>