public void UaTcpSessionChannelOptionsDefaults() { var shortestTimespan = TimeSpan.FromMilliseconds(100); var options = new UaTcpSessionChannelOptions(); TimeSpan.FromMilliseconds(options.SessionTimeout) .Should().BeGreaterOrEqualTo(shortestTimespan); }
/// <summary> /// Initializes a new instance of the <see cref="UaTcpSessionChannel"/> class. /// </summary> /// <param name="localDescription">The <see cref="ApplicationDescription"/> of the local application.</param> /// <param name="certificateStore">The local certificate store.</param> /// <param name="userIdentityProvider">An asynchronous function that provides the user identity. Provide an <see cref="AnonymousIdentity"/>, <see cref="UserNameIdentity"/>, <see cref="IssuedIdentity"/> or <see cref="X509Identity"/>.</param> /// <param name="remoteEndpoint">The <see cref="EndpointDescription"/> of the remote application. Obtained from a prior call to UaTcpDiscoveryClient.GetEndpoints.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="options">The session channel options.</param> public UaTcpSessionChannel( ApplicationDescription localDescription, ICertificateStore certificateStore, Func <EndpointDescription, Task <IUserIdentity> > userIdentityProvider, EndpointDescription remoteEndpoint, ILoggerFactory loggerFactory = null, UaTcpSessionChannelOptions options = null) : base(localDescription, certificateStore, remoteEndpoint, loggerFactory, options) { this.UserIdentityProvider = userIdentityProvider; this.options = options ?? new UaTcpSessionChannelOptions(); this.loggerFactory = loggerFactory; this.logger = loggerFactory?.CreateLogger <UaTcpSessionChannel>(); this.actionBlock = new ActionBlock <PublishResponse>(pr => this.OnPublishResponse(pr)); this.stateMachineCts = new CancellationTokenSource(); this.publishResponses = new BroadcastBlock <PublishResponse>(null, new DataflowBlockOptions { CancellationToken = this.stateMachineCts.Token }); }
/// <summary> /// Initializes a new instance of the <see cref="UaTcpSessionChannel"/> class. /// </summary> /// <param name="localDescription">The <see cref="ApplicationDescription"/> of the local application.</param> /// <param name="certificateStore">The local certificate store.</param> /// <param name="userIdentity">The user identity. Provide an <see cref="AnonymousIdentity"/>, <see cref="UserNameIdentity"/>, <see cref="IssuedIdentity"/> or <see cref="X509Identity"/>.</param> /// <param name="remoteEndpoint">The <see cref="EndpointDescription"/> of the remote application. Obtained from a prior call to UaTcpDiscoveryClient.GetEndpoints.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="options">The session channel options.</param> public UaTcpSessionChannel( ApplicationDescription localDescription, ICertificateStore?certificateStore, IUserIdentity userIdentity, EndpointDescription remoteEndpoint, ILoggerFactory?loggerFactory = null, UaTcpSessionChannelOptions?options = null) : base(localDescription, certificateStore, remoteEndpoint, loggerFactory, options) { UserIdentity = userIdentity; _options = options ?? new UaTcpSessionChannelOptions(); _loggerFactory = loggerFactory; _logger = loggerFactory?.CreateLogger <UaTcpSessionChannel>(); _actionBlock = new ActionBlock <PublishResponse>(pr => OnPublishResponse(pr)); _stateMachineCts = new CancellationTokenSource(); _publishResponses = new BroadcastBlock <PublishResponse>(null, new DataflowBlockOptions { CancellationToken = _stateMachineCts.Token }); }
/// <summary> /// Initializes a new instance of the <see cref="UaTcpSessionChannel"/> class. /// </summary> /// <param name="localDescription">The <see cref="ApplicationDescription"/> of the local application.</param> /// <param name="certificateStore">The local certificate store.</param> /// <param name="userIdentity">The user identity. Provide an <see cref="AnonymousIdentity"/>, <see cref="UserNameIdentity"/>, <see cref="IssuedIdentity"/> or <see cref="X509Identity"/>.</param> /// <param name="remoteEndpoint">The <see cref="EndpointDescription"/> of the remote application. Obtained from a prior call to UaTcpDiscoveryClient.GetEndpoints.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="options">The session channel options.</param> /// <param name="additionalTypes">Any additional types to be registered with encoder.</param> public UaTcpSessionChannel( ApplicationDescription localDescription, ICertificateStore?certificateStore, IUserIdentity userIdentity, EndpointDescription remoteEndpoint, ILoggerFactory?loggerFactory = null, UaTcpSessionChannelOptions?options = null, IEnumerable <Type>?additionalTypes = null) : base(localDescription, certificateStore, remoteEndpoint, loggerFactory, options, additionalTypes) { this.UserIdentity = userIdentity; this.options = options ?? new UaTcpSessionChannelOptions(); this.loggerFactory = loggerFactory; this.logger = loggerFactory?.CreateLogger <UaTcpSessionChannel>(); this.actionBlock = new ActionBlock <PublishResponse>(pr => this.OnPublishResponse(pr)); this.stateMachineCts = new CancellationTokenSource(); this.publishResponses = new BroadcastBlock <PublishResponse>(null, new DataflowBlockOptions { CancellationToken = this.stateMachineCts.Token }); }
/// <summary> /// Initializes a new instance of the <see cref="UaTcpSessionChannel"/> class. /// </summary> /// <param name="localDescription">The <see cref="ApplicationDescription"/> of the local application.</param> /// <param name="certificateStore">The local certificate store.</param> /// <param name="userIdentityProvider">An asynchronous function that provides the user identity. Provide an <see cref="AnonymousIdentity"/>, <see cref="UserNameIdentity"/>, <see cref="IssuedIdentity"/> or <see cref="X509Identity"/>.</param> /// <param name="endpointUrl">The url of the endpoint of the remote application</param> /// <param name="securityPolicyUri">Optionally, filter by SecurityPolicyUri.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="options">The session channel options.</param> public UaTcpSessionChannel( ApplicationDescription localDescription, ICertificateStore certificateStore, Func <EndpointDescription, Task <IUserIdentity> > userIdentityProvider, string endpointUrl, string?securityPolicyUri = null, ILoggerFactory?loggerFactory = null, UaTcpSessionChannelOptions?options = null) : base(localDescription, certificateStore, new EndpointDescription { EndpointUrl = endpointUrl, SecurityPolicyUri = securityPolicyUri }, loggerFactory, options) { UserIdentityProvider = userIdentityProvider; _options = options ?? new UaTcpSessionChannelOptions(); _loggerFactory = loggerFactory; _logger = loggerFactory?.CreateLogger <UaTcpSessionChannel>(); _actionBlock = new ActionBlock <PublishResponse>(pr => OnPublishResponse(pr)); _stateMachineCts = new CancellationTokenSource(); _publishResponses = new BroadcastBlock <PublishResponse>(null, new DataflowBlockOptions { CancellationToken = _stateMachineCts.Token }); }
/// <summary> /// Initializes a new instance of the <see cref="UaTcpSessionChannel"/> class. /// </summary> /// <param name="localDescription">The <see cref="ApplicationDescription"/> of the local application.</param> /// <param name="certificateStore">The local certificate store.</param> /// <param name="userIdentityProvider">An asynchronous function that provides the user identity. Provide an <see cref="AnonymousIdentity"/>, <see cref="UserNameIdentity"/>, <see cref="IssuedIdentity"/> or <see cref="X509Identity"/>.</param> /// <param name="endpointUrl">The url of the endpoint of the remote application</param> /// <param name="securityPolicyUri">Optionally, filter by SecurityPolicyUri.</param> /// <param name="loggerFactory">The logger factory.</param> /// <param name="options">The session channel options.</param> /// <param name="additionalTypes">Any additional types to be registered with encoder.</param> public UaTcpSessionChannel( ApplicationDescription localDescription, ICertificateStore certificateStore, Func <EndpointDescription, Task <IUserIdentity> > userIdentityProvider, string endpointUrl, string securityPolicyUri = null, ILoggerFactory loggerFactory = null, UaTcpSessionChannelOptions options = null, IEnumerable <Type> additionalTypes = null) : base(localDescription, certificateStore, new EndpointDescription { EndpointUrl = endpointUrl, SecurityPolicyUri = securityPolicyUri }, loggerFactory, options, additionalTypes) { this.UserIdentityProvider = userIdentityProvider; this.options = options ?? new UaTcpSessionChannelOptions(); this.loggerFactory = loggerFactory; this.logger = loggerFactory?.CreateLogger <UaTcpSessionChannel>(); this.actionBlock = new ActionBlock <PublishResponse>(pr => this.OnPublishResponse(pr)); this.stateMachineCts = new CancellationTokenSource(); this.publishResponses = new BroadcastBlock <PublishResponse>(null, new DataflowBlockOptions { CancellationToken = this.stateMachineCts.Token }); }