Table of Contents

Interface IAppWebHost

Namespace
VpnHood.AppLib.App.WebHosting
Assembly
VpnHood.AppLib.App.dll

Defines a place the app's own UI and API are served from (IAppWebHostFactory): the local one, on loopback, which this device loads its UI from, or the remote one, on the LAN's addresses, which a phone pairs with.

public interface IAppWebHost : IDisposable
Inherited Members

Properties

ConnectedDevices

Gets the devices seen in the last few seconds, which tells presence, not sessions; always empty for the local host, which serves this device only.

IReadOnlyList<IPAddress> ConnectedDevices { get; }

Property Value

IReadOnlyList<IPAddress>

IsActive

Gets a value indicating whether the host is bound now, or held open for the life of the process.

bool IsActive { get; }

Property Value

bool

IsAlwaysOn

Gets a value indicating whether the host is held open for the life of the process and asks for no pairing, as the remote host is in a Debug build or with the RemoteAccess command; always false for the local host.

bool IsAlwaysOn { get; }

Property Value

bool

Urls

Gets the addresses to dial in at, the best guess first, each with whatever the listener asks for on the first request: none before the host starts, and none after it stops unless it is always on. They change when the host binds again.

IReadOnlyList<Uri> Urls { get; }

Property Value

IReadOnlyList<Uri>

Methods

EnsureStarted(CancellationToken)

Starts the host where it is not, and returns the address to load, with the host bound and answering.

Task<Uri> EnsureStarted(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<Uri>

A task whose result is the address to load.

Remarks

The first call binds; a later one is its caller's sign that it could not reach the host, after a failed load or a resume, and costs one real connect. The remote host also reads its addresses again, as a network can change under an open pairing screen. Nothing is bound until a caller asks.

Exceptions

InvalidOperationException

The host could not be bound on any address.

ObjectDisposedException

The host is disposed.

OperationCanceledException

cancellationToken was canceled.

Stop(CancellationToken)

Lets the listeners go, until EnsureStarted(CancellationToken) binds them again; it does nothing while IsAlwaysOn. The app stops the remote host when the screen that opened it closes or a phone unpairs, and never stops the local one.

Task Stop(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Events

Restarted

Occurs when a listener was bound again under a caller that had loaded from it, so what it loaded may be half fetched: a page loaded from it reloads, and a phone tries again.

event EventHandler? Restarted

Event Type

EventHandler