Files
lmxopcua/src/Client/ZB.MOM.WW.OtOpcUa.Client.CLI/Commands/ConnectCommand.cs
T
Joseph Doherty 64e3fbe035
v2-ci / build (push) Failing after 1m43s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
docs: backfill XML documentation across 756 files
Adds <summary>, <param>, <typeparam>, and <inheritdoc/> tags to public
members surfaced by commentchecker — resolves 5,847 of 5,869 issues
(99.6%) across three /fixdocs passes.
2026-05-28 08:10:17 -04:00

43 lines
1.5 KiB
C#

using CliFx.Attributes;
using CliFx.Infrastructure;
using ZB.MOM.WW.OtOpcUa.Client.Shared;
namespace ZB.MOM.WW.OtOpcUa.Client.CLI.Commands;
[Command("connect", Description = "Test connection to an OPC UA server")]
public class ConnectCommand : CommandBase
{
/// <summary>
/// Creates the connectivity test command used to verify endpoint reachability and negotiated security settings.
/// </summary>
/// <param name="factory">The factory that creates the shared client service for the command run.</param>
public ConnectCommand(IOpcUaClientServiceFactory factory) : base(factory)
{
}
/// <inheritdoc />
public override async ValueTask ExecuteAsync(IConsole console)
{
ConfigureLogging();
IOpcUaClientService? service = null;
try
{
(service, var info) = await CreateServiceAndConnectAsync(console.RegisterCancellationHandler());
await console.Output.WriteLineAsync($"Connected to: {info.EndpointUrl}");
await console.Output.WriteLineAsync($"Server: {info.ServerName}");
await console.Output.WriteLineAsync($"Security Mode: {info.SecurityMode}");
await console.Output.WriteLineAsync($"Security Policy: {info.SecurityPolicyUri}");
await console.Output.WriteLineAsync("Connection successful.");
}
finally
{
if (service != null)
{
await service.DisconnectAsync();
service.Dispose();
}
}
}
}