Enable client support for multiple sessions on a single channel (#1659)

* Client API changes to support multiple sessions on a single channel
* Tested against freeopcua:python:server and ProSys simulation server
This commit is contained in:
Zigby
2022-04-01 14:27:32 +02:00
committed by GitHub
parent 0085597be2
commit cbe886dcb0
4 changed files with 208 additions and 31 deletions
+35 -9
View File
@@ -30,15 +30,7 @@ namespace Opc.Ua
{
if (channel == null) throw new ArgumentNullException(nameof(channel));
m_channel = channel;
m_useTransportChannel = true;
UaChannelBase uaChannel = channel as UaChannelBase;
if (uaChannel != null)
{
m_useTransportChannel = uaChannel.m_uaBypassChannel != null || uaChannel.UseBinaryEncoding;
}
InitializeChannel(channel);
}
#endregion
@@ -245,6 +237,23 @@ namespace Opc.Ua
#endregion
#region Public Methods
/// <summary>
/// Attach the channel to an already created client.
/// </summary>
/// <param name="channel">Channel to be used by the client</param>
public void AttachChannel(ITransportChannel channel)
{
InitializeChannel(channel);
}
/// <summary>
/// Detach the channel.
/// </summary>
public void DetachChannel()
{
m_channel = null;
}
/// <summary>
/// Closes the channel.
/// </summary>
@@ -282,6 +291,23 @@ namespace Opc.Ua
#endregion
#region Protected Methods
/// <summary>
/// Initializes the channel.
/// </summary>
/// <param name="channel"></param>
protected void InitializeChannel(ITransportChannel channel)
{
m_channel = channel;
m_useTransportChannel = true;
UaChannelBase uaChannel = channel as UaChannelBase;
if (uaChannel != null)
{
m_useTransportChannel = uaChannel.m_uaBypassChannel != null || uaChannel.UseBinaryEncoding;
}
}
/// <summary>
/// Closes the channel.
/// </summary>