Class Ap2Session
- Namespace
- AppleTvControlLibrary.Mrp.AirPlay
- Assembly
- AppleTvControlLibrary.Mrp.dll
High-level session for AirPlay 2: opens a control connection, runs pair-verify, and sets up the event and data-stream channels used to carry an MRP tunnel.
public sealed class Ap2Session : IDisposable
- Inheritance
-
Ap2Session
- Implements
- Inherited Members
Remarks
Initializes a new instance of the Ap2Session class.
Constructors
Ap2Session(string, int, HapCredentials, Ap2InfoSettings?)
High-level session for AirPlay 2: opens a control connection, runs pair-verify, and sets up the event and data-stream channels used to carry an MRP tunnel.
public Ap2Session(string address, int controlPort, HapCredentials credentials, Ap2InfoSettings? info = null)
Parameters
addressstringThe remote AirPlay control address.
controlPortintThe remote AirPlay control port.
credentialsHapCredentialsThe previously-paired HAP credentials for the device.
infoAp2InfoSettingsClient identity reported to the device during setup.
Remarks
Initializes a new instance of the Ap2Session class.
Properties
DataChannel
Gets the data-stream channel that carries the MRP tunnel, once SetupRemoteControlAsync(CancellationToken) has completed.
public DataStreamChannel? DataChannel { get; }
Property Value
Methods
ConnectAsync(CancellationToken)
Open the control connection and perform pair-verify.
public Task ConnectAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token used to cancel the connection attempt.
Returns
Dispose()
Close all open connections.
public void Dispose()
SetupRemoteControlAsync(CancellationToken)
Set up the event channel, RECORD the session, then set up the data channel used to carry MRP.
public Task SetupRemoteControlAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token used to cancel the exchanges.
Returns
StartKeepAlive()
Start sending periodic RTSP /feedback keep-alive requests on the control connection.
public void StartKeepAlive()
Remarks
Without this, the Apple TV closes the control (and therefore data-stream) connection a few seconds after RECORD completes. Must be called once SetupRemoteControlAsync(CancellationToken) has completed.
Events
KeepAliveFailed
Raised when the periodic feedback keep-alive fails after exhausting retries.
public event Action<Exception>? KeepAliveFailed
Event Type
KeepAliveFinished
Raised when the periodic feedback keep-alive stops because the connection was closed cleanly.
public event Action? KeepAliveFinished