Table of Contents

Interface ISessionAdHandler

Namespace
VpnHood.Core.Client
Assembly
VpnHood.Core.Client.dll

Represents a session's wait for an ad: while it waits, the session sends its new traffic around the tunnel, but the DNS and pings it carries as packets, so the ad loads through the device's own network, until the app tells it the ad's outcome.

public interface ISessionAdHandler : IDisposable
Inherited Members

Remarks

Disposing it cancels a wait under way.

Methods

SendRewardedAdData(string, CancellationToken)

Sends a rewarded ad's data to the server, for its access manager to verify, and ends the wait for the ad with the outcome.

Task SendRewardedAdData(string rewardedAdData, CancellationToken cancellationToken)

Parameters

rewardedAdData string

The ad's data.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once the server has taken the ad.

Remarks

A failure fails the wait for the ad with the same error, unless the session's shutdown has canceled it already.

Exceptions

ObjectDisposedException

The session is disposed.

OperationCanceledException

cancellationToken was canceled, or the session was disposed meanwhile.

Exception

The server answered the WebSocket upgrade otherwise than expected.

TimeoutException

The server did not answer in time.

SessionException

The server refused the ad or the session.

MaintenanceException

The server is in maintenance.

UnauthorizedAccessException

The server refused the request's proof.

SetAdFailed(Exception)

Ends the wait for an ad with its failure.

void SetAdFailed(Exception ex)

Parameters

ex Exception

The failure, which the wait throws.

Exceptions

ArgumentNullException

ex is null.

SetAdOk()

Ends the wait for an ad: the ad has been shown.

void SetAdOk()

WaitForAd(CancellationToken)

Starts a wait for an ad, or joins the one under way, until the app tells the ad's outcome.

Task WaitForAd(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that completes once the ad has been shown.

Remarks

The connections of the moment stay as they go when a wait starts. Once a wait it started ends, the session drops its TCP connections and forwarded ones, so the new ones follow the splits again.

Exceptions

OperationCanceledException

cancellationToken was canceled, or the handler or its session was disposed.

Exception

The ad failed: the error SetAdFailed(Exception) gave.