Skip to content
Merged
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
12 changes: 8 additions & 4 deletions Libraries/Opc.Ua.Server/Subscription/Subscription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,12 +1133,16 @@ private NotificationMessage ConstructMessage(
Diagnostics.NextSequenceNumber = m_sequenceNumber;
}

uint notificationLimit = m_maxNotificationsPerPublish == 0
? uint.MaxValue
: m_maxNotificationsPerPublish;

// add events.
if (events.Count > 0 && notificationCount < m_maxNotificationsPerPublish)
if (events.Count > 0 && notificationCount < notificationLimit)
{
var notification = new EventNotificationList();

while (events.Count > 0 && notificationCount < m_maxNotificationsPerPublish)
while (events.Count > 0 && notificationCount < notificationLimit)
{
notification.Events.Add(events.Dequeue());
notificationCount++;
Expand All @@ -1148,7 +1152,7 @@ private NotificationMessage ConstructMessage(
}

// add datachanges (space permitting).
if (datachanges.Count > 0 && notificationCount < m_maxNotificationsPerPublish)
if (datachanges.Count > 0 && notificationCount < notificationLimit)
{
bool diagnosticsExist = false;
var notification = new DataChangeNotification
Expand All @@ -1157,7 +1161,7 @@ private NotificationMessage ConstructMessage(
DiagnosticInfos = new DiagnosticInfoCollection(datachanges.Count)
};

while (datachanges.Count > 0 && notificationCount < m_maxNotificationsPerPublish)
while (datachanges.Count > 0 && notificationCount < notificationLimit)
{
MonitoredItemNotification datachange = datachanges.Dequeue();
notification.MonitoredItems.Add(datachange);
Expand Down
11 changes: 8 additions & 3 deletions Libraries/Opc.Ua.Server/Subscription/SubscriptionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1976,13 +1976,18 @@ protected virtual uint CalculateLifetimeCount(
/// </summary>
protected virtual uint CalculateMaxNotificationsPerPublish(uint maxNotificationsPerPublish)
{
if (maxNotificationsPerPublish == 0 ||
maxNotificationsPerPublish > m_maxNotificationsPerPublish)
if (maxNotificationsPerPublish == 0)
{
return m_maxNotificationsPerPublish;
}

return maxNotificationsPerPublish;
if (m_maxNotificationsPerPublish == 0 ||
maxNotificationsPerPublish <= m_maxNotificationsPerPublish)
{
return maxNotificationsPerPublish;
}

return m_maxNotificationsPerPublish;
}

/// <summary>
Expand Down
Loading
Loading