/* ========================================================================
* Copyright (c) 2005-2025 The OPC Foundation, Inc. All rights reserved.
*
* OPC Foundation MIT License 1.00
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* The complete license agreement can be found here:
* http://opcfoundation.org/License/MIT/1.00/
* ======================================================================*/
using System;
using System.Collections.Generic;
using Opc.Ua.Identity;
namespace Opc.Ua.Client
{
///
/// Options for creating a . Provided as a
/// record so it can be used with the .NET options pattern
/// () and bound
/// from configuration.
///
public sealed record ManagedSessionOptions
{
///
/// The configured endpoint to connect to. Required.
///
public ConfiguredEndpoint? Endpoint { get; init; }
///
/// Optional lazy identity provider. When both
/// and are set, the provider takes precedence
/// and can refresh identities after the session is connected.
///
public IClientIdentityProvider? IdentityProvider { get; init; }
///
/// Optional eager user identity. If null, the session uses anonymous.
/// When both and
/// are set, takes precedence.
///
[Obsolete(
"Use IdentityProvider for lazy/refresh-capable identities; the eager Identity setter " +
"cannot refresh on token expiry. See Docs/IdentityProviders.md.")]
public IUserIdentity? Identity { get; init; }
///
/// Optional time provider for proactive identity refresh scheduling.
///
public TimeProvider? TimeProvider { get; init; }
///
/// Session display name.
///
public string SessionName { get; init; } = "ManagedSession";
///
/// Requested session timeout. Defaults to 60 seconds.
///
public TimeSpan SessionTimeout { get; init; } = TimeSpan.FromSeconds(60);
///
/// Preferred locale identifiers (e.g. "en-US"). May be null.
///
public IReadOnlyList? PreferredLocales { get; init; }
///
/// Whether to validate the domain in the server certificate.
///
public bool CheckDomain { get; init; }
///
/// Reconnect policy configuration.
///
public ReconnectPolicyOptions ReconnectPolicy { get; init; } = new();
///
/// When set, server-side redundancy failover is enabled using a
/// default . To use a
/// custom handler, pass it explicitly to
/// .CreateAsync.
///
public bool EnableServerRedundancy { get; init; }
///
/// Optional subscription engine factory. When null, defaults to the
/// V2 engine () so
/// is available.
///
public ISubscriptionEngineFactory? SubscriptionEngineFactory { get; init; }
///
/// When true, opt the V2 subscription engine into
/// transfer-on-recreate. After a session re-create (e.g. a
/// ManagedSession failover via
/// Session.RecreateInPlaceAsync) the V2
/// first
/// attempts to transfer existing server-side subscriptions
/// from the previous session to the new one before falling
/// back to per-subscription recreate. Default: false
/// (recreate is the universal, server-agnostic fallback;
/// transfer requires server support and is opt-in).
///
///
/// Has no effect when the classic subscription engine is in
/// use, because the classic engine drives recreate through
/// the 's template-based path, not the
/// V2 manager.
///
public bool TransferSubscriptionsOnRecreate { get; init; }
///
///
/// When true, opt the V2 subscription engine into
/// activator-level pooling of notification payload instances.
/// After each publish dispatch the subscription calls
/// on notification objects
/// (such as MonitoredItemNotification), releasing them
/// back to their activator's pool for reuse on the next decode.
///
///
/// Handlers that retain references to notification values past
/// the dispatch call must copy the retained values before
/// returning from the handler — the pool may re-rent those
/// instances to other consumers immediately after the handler
/// returns. Default: false (opt-in).
///
///
/// Has no effect when the classic subscription engine is in
/// use; this option only applies to the V2
/// .
///
///
public bool PoolNotifications { get; init; }
///
///
/// When true, the automatically
/// enables address-space model change tracking once connected.
/// It subscribes to GeneralModelChangeEventType on the
/// server's notifier (and to SemanticChangeEventType),
/// invalidates the session's when changes
/// are reported, and exposes the changes via
/// .
///
///
/// Default: false. Enable for applications that cache
/// browse results long-term and need to react to dynamic
/// address-space changes (devices joining/leaving, type updates).
///
///
public bool ModelChangeTracking { get; init; }
}
}