Opc.Ua.Server.StandardServer.Publish C# (CSharp) Method

Publish() public method

Invokes the Publish service.
public Publish ( RequestHeader requestHeader, SubscriptionAcknowledgementCollection subscriptionAcknowledgements, uint &subscriptionId, UInt32Collection &availableSequenceNumbers, bool &moreNotifications, NotificationMessage &notificationMessage, StatusCodeCollection &results, DiagnosticInfoCollection &diagnosticInfos ) : ResponseHeader
requestHeader RequestHeader The request header.
subscriptionAcknowledgements SubscriptionAcknowledgementCollection The list of acknowledgements for one or more Subscriptions.
subscriptionId uint The subscription identifier.
availableSequenceNumbers UInt32Collection The available sequence numbers.
moreNotifications bool If set to true the number of Notifications that were ready to be sent could not be sent in a single response.
notificationMessage NotificationMessage The NotificationMessage that contains the list of Notifications.
results StatusCodeCollection The list of results for the acknowledgements.
diagnosticInfos DiagnosticInfoCollection The diagnostic information for the results.
return ResponseHeader
        public override ResponseHeader Publish(
            RequestHeader                         requestHeader, 
            SubscriptionAcknowledgementCollection subscriptionAcknowledgements, 
            out uint                              subscriptionId, 
            out UInt32Collection                  availableSequenceNumbers, 
            out bool                              moreNotifications, 
            out NotificationMessage               notificationMessage, 
            out StatusCodeCollection              results, 
            out DiagnosticInfoCollection          diagnosticInfos)
        {
            OperationContext context = ValidateRequest(requestHeader, RequestType.Publish);

            try
            {
                /*
                // check if there is an odd delay.
                if (DateTime.UtcNow > requestHeader.Timestamp.AddMilliseconds(100))
                {
                    Utils.Trace(
                        "WARNING. Unexpected delay receiving Publish request. Time={0:hh:mm:ss.fff}, ReceiveTime={1:hh:mm:ss.fff}",
                        DateTime.UtcNow,
                        requestHeader.Timestamp);
                }
                */
                
                // Utils.Trace("PUBLISH #{0} RECIEVED. TIME={1:hh:hh:ss.fff}", requestHeader.RequestHandle, requestHeader.Timestamp);
                
                notificationMessage = ServerInternal.SubscriptionManager.Publish(
                    context,
                    subscriptionAcknowledgements,
                    null,
                    out subscriptionId,
                    out availableSequenceNumbers,
                    out moreNotifications,
                    out results,
                    out diagnosticInfos);

                /*
                if (notificationMessage != null)
                {
                    Utils.Trace(
                        "PublishResponse: SubId={0} SeqNo={1}, PublishTime={2:mm:ss.fff}, Time={3:mm:ss.fff}",
                        subscriptionId,
                        notificationMessage.SequenceNumber,
                        notificationMessage.PublishTime,
                        DateTime.UtcNow);
                }
                */

                return CreateResponse(requestHeader, context.StringTable);      
            }
            catch (ServiceResultException e)
            {
                lock (ServerInternal.DiagnosticsLock)
                {
                    ServerInternal.ServerDiagnostics.RejectedRequestsCount++;

                    if (IsSecurityError(e.StatusCode))
                    {
                        ServerInternal.ServerDiagnostics.SecurityRejectedRequestsCount++;
                    }
                }

                throw TranslateException(context, e);
            }  
            finally
            {
                OnRequestComplete(context);
            }
        }