UaClient/ServiceModel/Ua/Channels/UaTcpSessionChannel.cs
/// <summary>
/// Sends publish requests to the server.
/// </summary>
/// <param name="token">A cancellation token.</param>
/// <returns>A task.</returns>
Sends publish requests to the server.
Sends publish requests to the server .
private async Task PublishAsync(CancellationToken token = default(CancellationToken))
        {
            var publishRequest = new PublishRequest
            {
                RequestHeader = new RequestHeader { TimeoutHint = PublishTimeoutHint, ReturnDiagnostics = this.options.DiagnosticsHint },
                SubscriptionAcknowledgements = new SubscriptionAcknowledgement[0]
            };
            while (!token.IsCancellationRequested)
            {
                try
                {
                    var publishResponse = await this.PublishAsync(publishRequest).WithCancellation(token).ConfigureAwait(false);
                    this.publishResponses.Post(publishResponse);
                    publishRequest = new PublishRequest
                    {
                        RequestHeader = new RequestHeader { TimeoutHint = PublishTimeoutHint, ReturnDiagnostics = this.options.DiagnosticsHint },
                        SubscriptionAcknowledgements = publishResponse.NotificationMessage.NotificationData != null ? new[] { new SubscriptionAcknowledgement { SequenceNumber = publishResponse.NotificationMessage.SequenceNumber, SubscriptionId = publishResponse.SubscriptionId } } : new SubscriptionAcknowledgement[0]
                    };
                }
                catch (Exception ex)
                {
                    if (token.IsCancellationRequested)
                    {
                        return;
                    }
                    this.logger?.LogError($"Error publishing subscription. {ex.Message}");
                    this.Fault(ex);
                    return;
                }
            }
        }
private async Task PublishAsync ( CancellationToken token = default ( CancellationToken ) ) { var publishRequest = new PublishRequest { RequestHeader = new RequestHeader { TimeoutHint = PublishTimeoutHint , ReturnDiagnostics = this . options . DiagnosticsHint } , SubscriptionAcknowledgements = new SubscriptionAcknowledgement [ 0 ] } ; while ( ! token . IsCancellationRequested ) { try { var publishResponse = await this . PublishAsync ( publishRequest ) . WithCancellation ( token ) . ConfigureAwait ( false ) ; this . publishResponses . Post ( publishResponse ) ; publishRequest = new PublishRequest { RequestHeader = new RequestHeader { TimeoutHint = PublishTimeoutHint , ReturnDiagnostics = this . options . DiagnosticsHint } , SubscriptionAcknowledgements = publishResponse . NotificationMessage . NotificationData != null ? new [ ] { new SubscriptionAcknowledgement { SequenceNumber = publishResponse . NotificationMessage . SequenceNumber , SubscriptionId = publishResponse . SubscriptionId } } : new SubscriptionAcknowledgement [ 0 ] } ; } catch ( Exception ex ) { if ( token . IsCancellationRequested ) { return ; } this . logger ? . LogError ( $" Error publishing subscription.  { ex . Message } " ) ; this . Fault ( ex ) ; return ; } } }
Sends publish requests to the server.
Sends publish requests to the server .
// post to linked data flow blocks and subscriptions.
None
token
CancellationToken
A cancellation token.
A cancellation token .