/* ======================================================================== * 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.Threading; using System.Threading.Tasks; using Opc.Ua.Security.Certificates; namespace Opc.Ua.Client { /// /// Object that creates instances of an ISessions object. /// public interface ISessionFactory { /// /// Set diagnostics for all sessions created by the factory /// DiagnosticsMasks ReturnDiagnostics { get; set; } /// /// Telemetry configuration to use when creating sessions. /// ITelemetryContext Telemetry { get; } /// /// Creates a new unconnected session with the channel to the server. /// /// The channel for the server. /// The configuration for the client application. /// The endpoint for the server. /// The certificate to use for the client. /// The certificate chain for the client cert. /// The list of available endpoints returned by /// server in GetEndpoints() response. /// The value of profileUris used in /// GetEndpoints() request. ISession Create( ITransportChannel channel, ApplicationConfiguration configuration, ConfiguredEndpoint endpoint, Certificate? clientCertificate = null, CertificateCollection? clientCertificateChain = null, ArrayOf availableEndpoints = default, ArrayOf discoveryProfileUris = default); /// /// Creates a new communication session with a server by invoking the CreateSession service /// /// The configuration for the client application. /// The endpoint for the server. /// If set to true the discovery endpoint is used /// to update the endpoint description before connecting. /// The name to assign to the session. /// The timeout period for the session. /// The identity. /// The user identity to associate with the session. /// The cancellation token /// The new session object Task CreateAsync( ApplicationConfiguration configuration, ConfiguredEndpoint endpoint, bool updateBeforeConnect, string sessionName, uint sessionTimeout, IUserIdentity? identity, ArrayOf preferredLocales, CancellationToken ct = default); /// /// Creates a new communication session with a server by invoking the CreateSession /// service /// /// The configuration for the client application. /// The endpoint for the server. /// If set to true the discovery endpoint is /// used to update the endpoint description before connecting. /// If set to true then the domain in the certificate /// must match the endpoint used. /// The name to assign to the session. /// The timeout period for the session. /// The user identity to associate with the session. /// The preferred locales. /// The cancellation token /// The new session object. Task CreateAsync( ApplicationConfiguration configuration, ConfiguredEndpoint endpoint, bool updateBeforeConnect, bool checkDomain, string sessionName, uint sessionTimeout, IUserIdentity? identity, ArrayOf preferredLocales, CancellationToken ct = default); /// /// Creates a secure channel to the specified endpoint. /// /// The application configuration. /// The client endpoint for the reverse connect. /// A configured endpoint to connect to. /// Update configuration based on server /// prior connect. /// Check that the certificate specifies a valid /// domain (computer) name. /// The cancellation token. /// A representing the asynchronous operation. Task CreateChannelAsync( ApplicationConfiguration configuration, ITransportWaitingConnection connection, ConfiguredEndpoint endpoint, bool updateBeforeConnect, bool checkDomain, CancellationToken ct = default); /// /// Creates a new communication session with a server using a reverse connection. /// /// The configuration for the client application. /// The client endpoint for the reverse connect. /// The endpoint for the server. /// If set to true the discovery endpoint /// is used to update the endpoint description before connecting. /// If set to true then the domain in the /// certificate must match the endpoint used. /// The name to assign to the session. /// The timeout period for the session. /// The user identity to associate with the session. /// The preferred locales. /// The cancellation token /// The new session object. Task CreateAsync( ApplicationConfiguration configuration, ITransportWaitingConnection connection, ConfiguredEndpoint endpoint, bool updateBeforeConnect, bool checkDomain, string sessionName, uint sessionTimeout, IUserIdentity? identity, ArrayOf preferredLocales, CancellationToken ct = default); /// /// Creates a new communication session with a server using a reverse connect manager. /// /// The configuration for the client application. /// The reverse connect manager for the client /// connection. /// The endpoint for the server. /// If set to true the discovery endpoint /// is used to update the endpoint description before connecting. /// If set to true then the domain in the certificate /// must match the endpoint used. /// The name to assign to the session. /// The timeout period for the session. /// The user identity to associate with the session. /// The preferred locales. /// The cancellation token. /// The new session object. Task CreateAsync( ApplicationConfiguration configuration, ReverseConnectManager reverseConnectManager, ConfiguredEndpoint endpoint, bool updateBeforeConnect, bool checkDomain, string sessionName, uint sessionTimeout, IUserIdentity? userIdentity, ArrayOf preferredLocales, CancellationToken ct = default); /// /// Recreates a session based on a specified template. /// /// The ISession object to use as template /// The cancellation token. /// The new session object. Task RecreateAsync( ISession sessionTemplate, CancellationToken ct = default); /// /// Recreates a session based on a specified template. /// /// The ISession object to use as template /// The waiting reverse connection. /// The cancellation token. /// The new session object. Task RecreateAsync( ISession sessionTemplate, ITransportWaitingConnection connection, CancellationToken ct = default); /// /// Recreates a session based on a specified template using the provided channel. /// /// The Session object to use as template /// The channel to use to recreate the session. /// The cancellation token. /// The new session object. Task RecreateAsync( ISession sessionTemplate, ITransportChannel transportChannel, CancellationToken ct = default); } }