/* ========================================================================
* 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 System.Threading;
using System.Threading.Tasks;
using Opc.Ua.Identity;
namespace Opc.Ua.Server
{
///
/// The interface that a server exposes to objects that it contains.
///
public interface IServerInternal : IAuditEventServer, IDisposable
{
///
/// The endpoint addresses used by the server.
///
/// The endpoint addresses.
IEnumerable EndpointAddresses { get; }
///
/// The context to use when serializing/deserializing extension objects.
///
/// The message context.
IServiceMessageContext MessageContext { get; }
///
/// The default system context for the server.
///
/// The default system context.
ServerSystemContext DefaultSystemContext { get; }
///
/// The table of namespace uris known to the server.
///
/// The namespace URIs.
NamespaceTable NamespaceUris { get; }
///
/// The table of remote server uris known to the server.
///
/// The server URIs.
StringTable ServerUris { get; }
///
/// The factory used to create encodeable objects that the server understands.
///
/// The factory.
IEncodeableFactory Factory { get; }
///
/// The datatypes, object types and variable types known to the server.
///
/// The type tree.
///
/// The type tree table is a global object that all components of a server have access to.
/// Node managers must populate this table with all types that they define.
/// This object is thread safe.
///
TypeTable TypeTree { get; }
///
/// The factory which helps creating main
/// node managers used by the server.
///
IMainNodeManagerFactory MainNodeManagerFactory { get; }
///
/// The master node manager for the server.
///
/// The node manager.
IMasterNodeManager NodeManager { get; }
///
/// The internal node manager for the servers.
///
/// The core node manager.
ICoreNodeManager CoreNodeManager { get; }
///
/// Returns the node manager that managers the server diagnostics.
///
/// The diagnostics node manager.
IDiagnosticsNodeManager DiagnosticsNodeManager { get; }
///
/// Returns the node manager that managers the server configuration.
///
/// The configuration node manager.
IConfigurationNodeManager ConfigurationNodeManager { get; }
///
/// The manager for events that all components use to queue events that occur.
///
/// The event manager.
EventManager EventManager { get; }
///
/// A manager for localized resources that components can use to localize text.
///
/// The resource manager.
ResourceManager ResourceManager { get; }
///
/// A manager for outstanding requests that allows components to receive notifications if the timeout or are cancelled.
///
/// The request manager.
RequestManager RequestManager { get; }
///
/// A manager for aggregate calculators supported by the server.
///
/// The aggregate manager.
AggregateManager AggregateManager { get; }
///
/// A manager for modelling rules supported by the server.
///
/// The modelling rules manager.
ModellingRulesManager ModellingRulesManager { get; }
///
/// The manager for active sessions.
///
/// The session manager.
ISessionManager SessionManager { get; }
///
/// The manager for role identity / application / endpoint mapping rules
/// per OPC UA Part 18 §6.4. null only on stripped-down server hosts
/// that don't expose Server.ServerCapabilities.RoleSet. Integrators may
/// override the default in-memory implementation by calling
/// before the address space is bound.
///
IRoleManager RoleManager { get; }
///
/// The registry that validates user identity tokens before falling back
/// to the legacy SessionManager.ImpersonateUser event. Integrators
/// may replace the default empty registry by calling
/// before sessions are activated.
///
IServerIdentityRegistry IdentityRegistry { get; }
///
/// The manager for the OPC UA Part 18 §5 user-management model.
/// null when the server doesn't expose
/// ServerConfiguration.UserManagement. Integrators inject a
/// concrete instance by calling .
///
UserManagement.IUserManagement? UserManagement { get; }
///
/// The manager for active subscriptions.
///
ISubscriptionManager SubscriptionManager { get; }
///
/// The factory for (durable) monitored item queues
///
IMonitoredItemQueueFactory MonitoredItemQueueFactory { get; }
///
/// The store to persist and retrieve subscriptions
///
ISubscriptionStore SubscriptionStore { get; }
///
/// The server's telemetry context
///
ITelemetryContext Telemetry { get; }
///
/// Whether the server is currently running.
///
///
/// true if this instance is running; otherwise, false.
///
///
/// This flag is set to false when the server shuts down. Threads running should check this flag whenever
/// they return from a blocking operation. If it is false the thread should clean up and terminate.
///
bool IsRunning { get; }
///
/// Returns the status object for the server.
///
/// The status.
[Obsolete("No longer thread safe. To read the value use CurrentState, to write use UpdateServerStatus.")]
ServerStatusValue Status { get; }
///
/// Gets or sets the current state of the server.
///
/// The state of the current.
ServerState CurrentState { get; set; }
///
/// Returns the Server object node
///
/// The Server object node.
ServerObjectState ServerObject { get; }
///
/// Used to synchronize access to the server diagnostics.
///
/// The diagnostics lock.
object DiagnosticsLock { get; }
///
/// Used to synchronize write access to the server diagnostics.
///
/// The diagnostics lock.
object DiagnosticsWriteLock { get; }
///
/// Returns the diagnostics structure for the server.
///
/// The server diagnostics.
ServerDiagnosticsSummaryDataType ServerDiagnostics { get; }
///
/// Whether the server is collecting diagnostics.
///
/// true if diagnostics is enabled; otherwise, false.
bool DiagnosticsEnabled { get; }
///
/// Closes the specified session.
///
/// The context.
/// The session identifier.
/// if set to true subscriptions are to be deleted.
[Obsolete("Use CloseSessionAsync instead.")]
void CloseSession(OperationContext context, NodeId sessionId, bool deleteSubscriptions);
///
/// Closes the specified session.
///
/// The context.
/// The session identifier.
/// if set to true subscriptions are to be deleted.
/// The cancellation token.
ValueTask CloseSessionAsync(
OperationContext context,
NodeId sessionId,
bool deleteSubscriptions,
CancellationToken cancellationToken = default);
///
/// Deletes the specified subscription.
///
/// The subscription identifier.
/// The cancellation token.
ValueTask DeleteSubscriptionAsync(uint subscriptionId, CancellationToken cancellationToken = default);
///
/// Called by any component to report a global event.
///
/// The event.
void ReportEvent(IFilterTarget e);
///
/// Called by any component to report a global event.
///
/// The context.
/// The event.
void ReportEvent(ISystemContext context, IFilterTarget e);
///
/// Refreshes the conditions for the specified subscription.
///
/// The context.
/// The subscription identifier.
void ConditionRefresh(OperationContext context, uint subscriptionId);
///
/// Refreshes the conditions for the specified subscription and monitored item.
///
/// The context.
/// The subscription identifier.
/// The monitored item identifier.
void ConditionRefresh2(OperationContext context, uint subscriptionId, uint monitoredItemId);
///
/// Sets the EventManager, the ResourceManager, the RequestManager and the AggregateManager.
///
/// The event manager.
/// The resource manager.
/// The request manager.
/// The cancellation token.
ValueTask CreateServerObjectAsync(
EventManager eventManager,
ResourceManager resourceManager,
RequestManager requestManager,
CancellationToken cancellationToken = default);
///
/// Stores the MasterNodeManager and the CoreNodeManager
///
/// The node manager.
void SetNodeManager(IMasterNodeManager nodeManager);
///
/// Stores the MainNodeManagerFactory
///
/// The main node manager factory.
void SetMainNodeManagerFactory(IMainNodeManagerFactory mainNodeManagerFactory);
///
/// Stores the SessionManager, the SubscriptionManager in the datastore.
///
/// The session manager.
/// The subscription manager.
void SetSessionManager(
ISessionManager sessionManager,
ISubscriptionManager subscriptionManager);
///
/// Stores the MonitoredItemQueueFactory in the datastore.
///
/// The MonitoredItemQueueFactory.
void SetMonitoredItemQueueFactory(IMonitoredItemQueueFactory monitoredItemQueueFactory);
///
/// Stores the Subscriptionstore in the datastore.
///
/// The subscriptionstore.
void SetSubscriptionStore(ISubscriptionStore subscriptionStore);
///
/// Replaces the role manager with a custom
/// implementation. Must be called before the diagnostics node manager
/// binds the address space (typically before StartServer).
/// Integrators use this to plug a persistent backing store, an LDAP
/// directory, etc., in place of the default in-memory
/// .
///
/// The role manager to use.
void SetRoleManager(IRoleManager roleManager);
///
/// Replaces the identity registry with a custom
/// implementation. Must be
/// called before sessions are activated so authenticators can run
/// ahead of the legacy impersonation event.
///
/// The identity registry to use.
void SetIdentityRegistry(IServerIdentityRegistry registry);
///
/// Replaces the user-management facade with a custom
///
/// implementation. Must be called before the configuration node
/// manager binds the address space (typically before StartServer).
///
/// The user-management facade.
void SetUserManagement(UserManagement.IUserManagement userManagement);
///
/// Stores the AggregateManager in the datastore.
///
/// The AggregateManager.
void SetAggregateManager(AggregateManager aggregateManager);
///
/// Stores the ModellingRulesManager in the datastore.
///
/// The ModellingRulesManager.
void SetModellingRulesManager(ModellingRulesManager modellingRulesManager);
///
/// Updates the server status safely.
///
/// Action to perform on the server status object.
void UpdateServerStatus(Action action);
}
}