Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnTokenActivated event for token change notifications #2868

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Stack/Opc.Ua.Core/Stack/Client/UaChannelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,13 @@
/// </summary>
public ChannelToken CurrentToken => null;

/// <inheritdoc/>
public event ChannelTokenActivatedEventHandler OnTokenActivated
{
add { }
remove { }

Check warning on line 205 in Stack/Opc.Ua.Core/Stack/Client/UaChannelBase.cs

View check run for this annotation

Codecov / codecov/patch

Stack/Opc.Ua.Core/Stack/Client/UaChannelBase.cs#L204-L205

Added lines #L204 - L205 were not covered by tests
}

/// <summary>
/// Gets or sets the default timeout for requests send via the channel.
/// </summary>
Expand Down Expand Up @@ -685,7 +692,7 @@
#endregion
}
#endregion

/// <summary>
/// Processes the request.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Stack/Opc.Ua.Core/Stack/Https/HttpsTransportChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@
/// <inheritdoc/>
public ChannelToken CurrentToken => null;

/// <inheritdoc/>
public event ChannelTokenActivatedEventHandler OnTokenActivated
{
add { }
remove { }

Check warning on line 115 in Stack/Opc.Ua.Core/Stack/Https/HttpsTransportChannel.cs

View check run for this annotation

Codecov / codecov/patch

Stack/Opc.Ua.Core/Stack/Https/HttpsTransportChannel.cs#L114-L115

Added lines #L114 - L115 were not covered by tests
}

/// <inheritdoc/>
public int OperationTimeout
{
Expand Down
19 changes: 14 additions & 5 deletions Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryChannel.Symmetric.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public partial class UaSCUaBinaryChannel
/// </summary>
protected ChannelToken RenewedToken => m_renewedToken;

/// <summary>
/// Called when the token changes
/// </summary>
protected internal ChannelTokenActivatedEventHandler OnTokenActivated { get; set; }

/// <summary>
/// Creates a new token.
/// </summary>
Expand Down Expand Up @@ -66,6 +71,8 @@ protected void ActivateToken(ChannelToken token)
m_currentToken = token;
m_renewedToken = null;

OnTokenActivated?.Invoke(token, m_previousToken);

Utils.LogInfo("ChannelId {0}: Token #{1} activated. CreatedAt={2:HH:mm:ss.fff}. Lifetime={3}.", Id, token.TokenId, token.CreatedAt, token.Lifetime);
}

Expand All @@ -85,13 +92,15 @@ protected void DiscardTokens()
{
m_previousToken = null;
m_currentToken = null;

OnTokenActivated?.Invoke(null, null);
}
#endregion

#region Symmetric Cryptography Functions
/// <summary>
/// Indicates that an explicit signature is not present.
/// </summary>
/// </summary>
private bool UseAuthenticatedEncryption
{
get; set;
Expand Down Expand Up @@ -376,7 +385,7 @@ protected void ComputeKeys(ChannelToken token)
case SecurityPolicies.ECC_brainpoolP256r1:
case SecurityPolicies.ECC_brainpoolP384r1:
{
// create encryptors.
// create encryptors.
SymmetricAlgorithm AesCbcEncryptorProvider = Aes.Create();
AesCbcEncryptorProvider.Mode = CipherMode.CBC;
AesCbcEncryptorProvider.Padding = PaddingMode.None;
Expand Down Expand Up @@ -1137,7 +1146,7 @@ private static void SymmetricEncryptWithChaCha20Poly1305(
// Utils.Trace($"EncryptIV2={Utils.ToHexString(iv)}");

int signatureLength = 16;

var plaintext = dataToEncrypt.Array;
int headerSize = dataToEncrypt.Offset;
int plainTextLength = dataToEncrypt.Offset + dataToEncrypt.Count - signatureLength;
Expand All @@ -1149,7 +1158,7 @@ private static void SymmetricEncryptWithChaCha20Poly1305(
signatureLength * 8,
iv,
null);

ChaCha20Poly1305 encryptor = new ChaCha20Poly1305();
encryptor.Init(true, parameters);
encryptor.ProcessAadBytes(plaintext, 0, headerSize);
Expand All @@ -1162,7 +1171,7 @@ private static void SymmetricEncryptWithChaCha20Poly1305(
if (ciphertext.Length - headerSize != length)
{
throw ServiceResultException.Create(
StatusCodes.BadSecurityChecksFailed,
StatusCodes.BadSecurityChecksFailed,
$"Cipher text not the expected size. [{ciphertext.Length - headerSize} != {length}]");
}

Expand Down
16 changes: 9 additions & 7 deletions Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@

if (disposing)
{
OnTokenActivated = null;

Utils.SilentDispose(m_handshakeTimer);
m_handshakeTimer = null;
}
Expand Down Expand Up @@ -488,7 +490,7 @@
decoder.Close();
}


// ready to open the channel.
State = TcpChannelState.Opening;

Expand Down Expand Up @@ -567,7 +569,7 @@
{
Utils.LogTrace("ChannelId {0}: ProcessOpenSecureChannelResponse()", ChannelId);

// validate the channel state.
// validate the channel state.
if (State != TcpChannelState.Opening && State != TcpChannelState.Open)
{
ForceReconnect(ServiceResult.Create(StatusCodes.BadTcpMessageTypeInvalid, "Server sent an unexpected OpenSecureChannel response."));
Expand Down Expand Up @@ -631,7 +633,7 @@
throw ServiceResultException.Create(StatusCodes.BadTypeMismatch, "Server did not return a valid OpenSecureChannelResponse.");
}

// the client needs to use the creation time assigned when it sent
// the client needs to use the creation time assigned when it sent
// the request and ignores the creation time in the response because
// the server and client clocks may not be synchronized.

Expand All @@ -645,7 +647,7 @@
throw new ServiceResultException(StatusCodes.BadNonceInvalid);
}

string implementation = String.Format(g_ImplementationString, m_socketFactory.Implementation);

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Security.Certificates

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Security.Certificates

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Configuration

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Configuration

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Gds

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-PubSub

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Core

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Core

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Client.ComplexTypes

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Server

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Configuration

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Configuration

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Client.ComplexTypes

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Security.Certificates

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Security.Certificates

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Gds

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-PubSub

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Core

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Core

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Server

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Client

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

Check warning on line 650 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryClientChannel.cs

View workflow job for this annotation

GitHub Actions / test-windows-latest-Client

The behavior of 'string.Format(string, object)' could vary based on the current user's locale settings. Replace this call in 'UaSCUaBinaryClientChannel.ProcessOpenSecureChannelResponse(uint, ArraySegment<byte>)' with a call to 'string.Format(IFormatProvider, string, params object[])'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1305)

// log security information.
if (State == TcpChannelState.Opening)
Expand Down Expand Up @@ -674,7 +676,7 @@
State = TcpChannelState.Open;
m_reconnecting = false;

// enable reconnects. DO NOT USE!
// enable reconnects. DO NOT USE!
// m_waitBetweenReconnects = TcpMessageLimits.MinTimeBetweenReconnects;
m_waitBetweenReconnects = Timeout.Infinite;

Expand Down Expand Up @@ -1153,7 +1155,7 @@
Socket = null;
}

// set the state.
// set the state.
ChannelStateChanged(TcpChannelState.Closed, reason);
}
}
Expand Down Expand Up @@ -1270,7 +1272,7 @@
}

/// <summary>
/// Creates an object to manage the state of an asynchronous operation.
/// Creates an object to manage the state of an asynchronous operation.
/// </summary>
private WriteOperation BeginOperation(int timeout, AsyncCallback callback, object state)
{
Expand Down Expand Up @@ -1410,7 +1412,7 @@
{
ServiceResult error;

// read request buffer sizes.
// read request buffer sizes.
using (var decoder = new BinaryDecoder(messageChunk, Quotas.MessageContext))
{
ReadAndVerifyMessageTypeAndSize(decoder, TcpMessageType.Error, messageChunk.Count);
Expand Down
13 changes: 13 additions & 0 deletions Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryTransportChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
#endregion

#region ITransportChannel Members

/// <summary>
/// Called when the token changes
/// </summary>
public event ChannelTokenActivatedEventHandler OnTokenActivated
{
add => m_OnTokenActivated += value;
remove => m_OnTokenActivated -= value;

Check warning on line 80 in Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryTransportChannel.cs

View check run for this annotation

Codecov / codecov/patch

Stack/Opc.Ua.Core/Stack/Tcp/UaSCBinaryTransportChannel.cs#L79-L80

Added lines #L79 - L80 were not covered by tests
}

/// <summary>
/// A masking indicating which features are implemented.
/// </summary>
Expand Down Expand Up @@ -482,6 +492,8 @@
channel.ReverseSocket = true;
}

// Register the token changed event handler with the internal channel
channel.OnTokenActivated = m_OnTokenActivated;
return channel;
}
#endregion
Expand All @@ -494,6 +506,7 @@
private ChannelQuotas m_quotas;
private BufferManager m_bufferManager;
private UaSCUaBinaryClientChannel m_channel;
private event ChannelTokenActivatedEventHandler m_OnTokenActivated;
private IMessageSocketFactory m_messageSocketFactory;
#endregion
}
Expand Down
16 changes: 14 additions & 2 deletions Stack/Opc.Ua.Core/Stack/Transport/ITransportChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
namespace Opc.Ua
{
/// <summary>
/// This is an interface to a channel which supports
/// Callback when the token is activated
/// </summary>
/// <param name="currentToken"></param>
/// <param name="previousToken"></param>
public delegate void ChannelTokenActivatedEventHandler(ChannelToken currentToken, ChannelToken previousToken);

/// <summary>
/// This is an interface to a channel which supports
/// </summary>
public interface ITransportChannel : IDisposable
{
Expand Down Expand Up @@ -47,6 +54,11 @@ public interface ITransportChannel : IDisposable
/// </summary>
ChannelToken CurrentToken { get; }

/// <summary>
/// Register for token change events
/// </summary>
event ChannelTokenActivatedEventHandler OnTokenActivated;

/// <summary>
/// Gets or sets the default timeout for requests send via the channel.
/// </summary>
Expand Down Expand Up @@ -200,7 +212,7 @@ IAsyncResult BeginOpen(

/// <summary>
/// Completes an asynchronous operation to send a request over the secure channel.
/// Awaitable version
/// Awaitable version
/// </summary>
/// <param name="result">The result returned from the BeginSendRequest call.</param>
/// <param name="ct">The cancellation token.</param>
Expand Down
Loading