Runtime class
Produces a process's sessions. Create it after Library.Init; every
Session comes from Runtime.Onboard on it.
Namespace: Quaternar.Qaros · Assembly: Quaternar.Qaros.dll
public sealed class Runtime : IDisposable
Implements: IDisposable
Remarks
The canonical startup: Runtime.Onboard on every start, nothing persisted. An app on
the hub's PC (also one QAROS launched) uses OnboardOptions.UseLocalApp; its
companion process uses OnboardOptions.UseInvite on a runtime created with
RuntimeOptions.EphemeralStorage; on a member hub's PC an app first runs
Runtime.JoinHubAsMember, then onboards as a local app redeeming
OnboardLocalApp.RemoteAppGrant.
Dispose sessions before the runtime, and the runtime before Library.Destroy.
Methods
| Member | Description |
|---|---|
| Create(RuntimeOptions?) | Creates the runtime. Set RuntimeOptions.RuntimeBinariesFolderPath to the SDK bin folder the native library was loaded from: left empty, sessions still work but Session.InviteTargetApp never completes. |
| Rejoin(RejoinOptions, IProgress<ActionProgress>?, CancellationToken) | Deprecated: restores the session last persisted for RejoinOptions.OnboardingId. Blocks until the restore validated or failed. Onboard with OnboardOptions.UseLocalApp or OnboardOptions.UseInvite on every start instead. |
| RejoinAsync(RejoinOptions, IProgress<ActionProgress>?, CancellationToken) | Deprecated async Runtime.Rejoin: returns at once, and the task completes on a library thread with the same results. |
| Onboard(OnboardOptions, IProgress<ActionProgress>?, CancellationToken) | Joins the session with the mode chosen by OnboardOptions.UseLocalApp or OnboardOptions.UseInvite, and blocks until it succeeded or failed. Call it on every start: neither mode persists anything to come back to. |
| OnboardAsync(OnboardOptions, IProgress<ActionProgress>?, CancellationToken) | Async Runtime.Onboard: returns at once and keeps the UI responsive; the task completes with the same results. Canceling cancellationToken cancels the task. |
| Forget(ForgetOptions) | Deprecated: erases everything stored for an identity slot: certificate, persisted peer id and session state. A local-app or invite onboarding persists nothing to forget; revoke a local app's approval in the QAROS hub instead. |
| CreateMemberHubInvitation(MemberHubInvitationOptions, CancellationToken) | Member-hub invitation, on the primary hub's PC: asks the QAROS hub on this PC, the session's primary, for an invitation that joins the hub on another PC as its member. Carry its MemberHubInvitation.Serialize bytes to your app on that PC, which calls Runtime.JoinHubAsMember. Blocks until the hub answers. Needs no session. |
| JoinHubAsMember(JoinHubAsMemberOptions, IProgress<ActionProgress>?, CancellationToken) | Member-hub invitation, on the joining PC: joins the QAROS hub on this PC to the invitation's primary hub as a member. It does not onboard this app: call Runtime.Onboard with a local-app onboarding afterwards, which then needs no prompt. |
| Dispose() | Releases this process's runtime handle. Dispose its sessions first. Does not shut down the shared Hub or other applications using it. |
Create
Creates the runtime. Set RuntimeOptions.RuntimeBinariesFolderPath to the
SDK bin folder the native library was loaded from: left empty, sessions still
work but Session.InviteTargetApp never completes.
public static Result<Runtime> Create(RuntimeOptions? options = null)
Parameters
| Name | Type | Description |
|---|---|---|
options | RuntimeOptions |
Rejoin
Deprecated: restores the session last persisted for
RejoinOptions.OnboardingId. Blocks until the restore validated or failed.
Onboard with OnboardOptions.UseLocalApp or
OnboardOptions.UseInvite on every start instead.
[Obsolete("Persisted identity slots are deprecated: onboard on every start with OnboardOptions.UseLocalApp, or OnboardOptions.UseInvite for a companion process.")]
public Result<Session> Rejoin(RejoinOptions options, IProgress<ActionProgress>? progress = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | RejoinOptions | The onboarding id to restore, and optional presentation and GPU. |
progress | IProgress<ActionProgress> | Optional progress reports. |
cancellationToken | CancellationToken | Cancels the restore; the call then returns a failure. |
Remarks
The session keeps the peer id the onboard persisted. Presentation fields left null keep their persisted values.
Expected failures: StatusCode.OnboardingSessionNotFound means this slot has
nothing persisted here, fall back to Runtime.Onboard.
StatusCode.ArgumentNotSupported means the onboarding id is
OnboardingId.Default, or the runtime was created with
RuntimeOptions.EphemeralStorage, which persists no slot.
progress is reported from a library thread while this call blocks.
A Progress<T> created on a UI thread posts there, so do not block that
thread on this call if you want to see the reports.
RejoinAsync
Deprecated async Runtime.Rejoin: returns at once, and the task completes on a
library thread with the same results.
[Obsolete("Persisted identity slots are deprecated: onboard on every start with OnboardOptions.UseLocalApp, or OnboardOptions.UseInvite for a companion process.")]
public Task<Result<Session>> RejoinAsync(RejoinOptions options, IProgress<ActionProgress>? progress = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | RejoinOptions | |
progress | IProgress<ActionProgress> | |
cancellationToken | CancellationToken |
Returns: Task<Result<Session>>
Onboard
Joins the session with the mode chosen by OnboardOptions.UseLocalApp or
OnboardOptions.UseInvite, and blocks until it succeeded or failed. Call it
on every start: neither mode persists anything to come back to.
public Result<OnboardSession> Onboard(OnboardOptions options, IProgress<ActionProgress>? progress = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | OnboardOptions | The onboarding mode and its optional extensions. |
progress | IProgress<ActionProgress> | Optional progress reports, for an onboarding UI. |
cancellationToken | CancellationToken | Cancels the onboarding; the call then returns a failure. |
Returns: Result<OnboardSession>
Remarks
Expected failures: StatusCode.OnboardingApprovalDenied means the user
denied the app in the QAROS hub, or another executable already redeemed the
OnboardLocalApp.RemoteAppGrant; StatusCode.OnboardingApprovalTimeout
means nobody answered the approval prompt. StatusCode.OnboardingHubUnreachable
means no hub answered: check that it runs. An invite onboarding retries by itself and
fails only for what no retry changes: a forged invite, the approval denied, or the app
session that minted the invite gone. StatusCode.ArgumentNotSupported means an
OnboardLocalApp.Tag the runtime refuses, an invalid
OnboardLocalApp.RemoteAppGrant, or a GPU the session cannot create its
devices on.
The returned OnboardSession.OnboardingId serves only the deprecated slot
paths; with RuntimeOptions.EphemeralStorage it is
OnboardingId.Default.
progress is reported from a library thread while this call blocks.
OnboardAsync
Async Runtime.Onboard: returns at once and keeps the UI responsive; the task
completes with the same results. Canceling cancellationToken cancels
the task.
public Task<Result<OnboardSession>> OnboardAsync(OnboardOptions options, IProgress<ActionProgress>? progress = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | OnboardOptions | |
progress | IProgress<ActionProgress> | |
cancellationToken | CancellationToken |
Returns: Task<Result<OnboardSession>>
Forget
Deprecated: erases everything stored for an identity slot: certificate, persisted peer id and session state. A local-app or invite onboarding persists nothing to forget; revoke a local app's approval in the QAROS hub instead.
[Obsolete("Persisted identity slots are deprecated: OnboardOptions.UseLocalApp and OnboardOptions.UseInvite persist nothing to forget; revoke a local app's approval in the QAROS hub.")]
public Result<Unit> Forget(ForgetOptions options)
Parameters
| Name | Type | Description |
|---|---|---|
options | ForgetOptions |
Remarks
Fails with StatusCode.OnboardingSessionStillActive while a session of the
slot is alive: dispose it first. A slot with nothing persisted fails with
StatusCode.OnboardingSessionNotFound. A runtime created with
RuntimeOptions.EphemeralStorage has no slots and fails with
StatusCode.ArgumentNotSupported.
CreateMemberHubInvitation
Member-hub invitation, on the primary hub's PC: asks the QAROS hub on this PC, the
session's primary, for an invitation that joins the hub on another PC as its member. Carry
its MemberHubInvitation.Serialize bytes to your app on that PC, which calls
Runtime.JoinHubAsMember. Blocks until the hub answers. Needs no session.
public Result<MemberHubInvitation> CreateMemberHubInvitation(MemberHubInvitationOptions options, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | MemberHubInvitationOptions | |
cancellationToken | CancellationToken |
Returns: Result<MemberHubInvitation>
Remarks
The hub identifies this process from Windows and answers only an app it approved with
"May bring in member hubs" and quota left; the quota is spent per hub admitted. It never
prompts. The invitation is a secret bearer credential: send it only over a trusted channel
and never log it. Expected failures: StatusCode.OnboardingHubUnreachable,
StatusCode.OnboardingApprovalDenied,
StatusCode.MemberSponsorNotAllowed,
StatusCode.MemberSponsorQuotaExceeded,
StatusCode.ArgumentNotSupported (an option out of range, or a
MemberHubInvitationOptions.AppTag the runtime refuses). The caller owns
and disposes the invitation. Windows only.
JoinHubAsMember
Member-hub invitation, on the joining PC: joins the QAROS hub on this PC to the
invitation's primary hub as a member. It does not onboard this app: call
Runtime.Onboard with a local-app onboarding afterwards, which then needs no prompt.
public Result<Unit> JoinHubAsMember(JoinHubAsMemberOptions options, IProgress<ActionProgress>? progress = null, CancellationToken cancellationToken = default)
Parameters
| Name | Type | Description |
|---|---|---|
options | JoinHubAsMemberOptions | |
progress | IProgress<ActionProgress> | |
cancellationToken | CancellationToken |
Remarks
Starts the installed hub when none runs, checks the invitation (signature, expiry, then
the administrator's allow-list or the primary this PC's hub joined first), joins, rejoins
or readmits the hub, and blocks through its restart into the primary's session. Called
again on a hub that already is a member of that primary, it succeeds at once. Any process
of this PC's user may call it: the signed invitation authorizes the join. Expected
failures: StatusCode.MemberInvitationInvalid,
StatusCode.MemberInvitationExpired,
StatusCode.MemberInvitationUsedUp,
StatusCode.MemberInvitationRevoked,
StatusCode.MemberInvitationPrimaryNotAllowed,
StatusCode.MemberInvitationPolicyNotProtected,
StatusCode.MemberJoinRefused, StatusCode.MemberRemoved,
StatusCode.PrimaryUnreachable,
StatusCode.HubLifecycleOperationRunning,
StatusCode.OnboardingHubUnreachable and StatusCode.Timeout
(the join stays committed; calling again succeeds once the hub is back). Windows only.
Dispose
Releases this process's runtime handle. Dispose its sessions first. Does not shut down the shared Hub or other applications using it.
public void Dispose()
Exceptions
| Exception | Condition |
|---|---|
| InvalidOperationException | Called from a QAROS callback where it would have to wait (see remarks). |
Remarks
Safe while another thread is inside a call on the runtime: new calls are refused at once
(ObjectDisposedException), the calls that wait on the hub
(Runtime.Onboard, the deprecated Runtime.Rejoin, their async forms,
Runtime.JoinHubAsMember, Runtime.CreateMemberHubInvitation) are cancelled and
fail, and Dispose waits until every running call returned and every async call's
completion fired. Only then is the runtime released, on the calling thread, so a
Library.Destroy may follow at once. The wait is not bounded: do not call it
from a QAROS callback or event handler, whose library thread a completion it waits for
may need. From a progress report of a runtime call, or from another callback while a
runtime call runs, it throws InvalidOperationException instead of waiting.