Implements Client.Shared (IOpcUaClientService with connection lifecycle, failover, browse, read/write, subscriptions, alarms, history, redundancy), Client.CLI (8 CliFx commands mirroring tools/opcuacli-dotnet), and Client.UI (Avalonia desktop app with tree browser, read/write, subscriptions, alarms, and history tabs). All three target .NET 10 and are covered by 249 unit tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using Opc.Ua;
|
|
using Opc.Ua.Client;
|
|
using Serilog;
|
|
|
|
namespace ZB.MOM.WW.LmxOpcUa.Client.Shared.Adapters;
|
|
|
|
/// <summary>
|
|
/// Production session factory that creates real OPC UA sessions.
|
|
/// </summary>
|
|
internal sealed class DefaultSessionFactory : ISessionFactory
|
|
{
|
|
private static readonly ILogger Logger = Log.ForContext<DefaultSessionFactory>();
|
|
|
|
public async Task<ISessionAdapter> CreateSessionAsync(
|
|
ApplicationConfiguration config,
|
|
EndpointDescription endpoint,
|
|
string sessionName,
|
|
uint sessionTimeoutMs,
|
|
UserIdentity identity,
|
|
CancellationToken ct)
|
|
{
|
|
var endpointConfig = EndpointConfiguration.Create(config);
|
|
var configuredEndpoint = new ConfiguredEndpoint(null, endpoint, endpointConfig);
|
|
|
|
var session = await Session.Create(
|
|
config,
|
|
configuredEndpoint,
|
|
false,
|
|
sessionName,
|
|
sessionTimeoutMs,
|
|
identity,
|
|
null);
|
|
|
|
Logger.Information("Session created: {SessionName} -> {EndpointUrl}", sessionName, endpoint.EndpointUrl);
|
|
return new DefaultSessionAdapter(session);
|
|
}
|
|
}
|